Skip to content
Snippets Groups Projects
Commit 5b1e982a authored by Maksym Trofimenko's avatar Maksym Trofimenko
Browse files

update handler

parent 9bc11517
No related merge requests found
......@@ -114,16 +114,18 @@ func (r *Registry) homeHandler(w http.ResponseWriter, req *http.Request) error {
}
func (r *Registry) Handle(resp http.ResponseWriter, req *http.Request) {
if r.debug {
r.log.Printf("%s - %s", req.Method, req.URL)
}
if err := r.v2(resp, req); err != nil {
var regErr *rerrros.RegError
if errors.As(err, &regErr) {
r.log.Printf("%s %s %d %s %s", req.Method, req.URL, regErr.Status, regErr.Code, regErr.Message)
_ = regErr.Write(resp)
}
return
}
if r.debug {
r.log.Printf("%s - %s", req.Method, req.URL)
http.Error(resp, err.Error(), http.StatusInternalServerError)
return
}
}
......@@ -200,15 +202,6 @@ func Cache(c manifest.Cache) Option {
}
}
func PathPrefix(v string) Option {
return func(r *Registry) {
if v == "/" {
return
}
r.pathPrefix = v
}
}
func prettyEncode(data interface{}, out io.Writer) error {
enc := json.NewEncoder(out)
enc.SetIndent("", " ")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment