proxy: use custom 404 handler (#348)

Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
Bobby DeSimone 2019-10-04 08:36:23 -07:00 committed by GitHub
parent eaa1e7a4fb
commit 7016534d87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -168,6 +168,9 @@ func (p *Proxy) UpdatePolicies(opts *config.Options) error {
log.Warn().Msg("proxy: configuration has no policies")
}
r := httputil.NewRouter()
r.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
httputil.ErrorResponse(w, r, httputil.Error(fmt.Sprintf("%s route unknown", r.Host), http.StatusNotFound, nil))
})
r.SkipClean(true)
r.StrictSlash(true)
r.HandleFunc("/robots.txt", p.RobotsTxt).Methods(http.MethodGet)