|
|
|
@ -7,6 +7,7 @@
|
|
|
|
|
package router |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"expvar" |
|
|
|
|
"net/http" |
|
|
|
|
|
|
|
|
|
"forge.chapril.org/mls-361/jsonapi" |
|
|
|
@ -34,6 +35,14 @@ func Build(_ *components.Components) components.Router {
|
|
|
|
|
rw.WriteHeader(http.StatusInternalServerError) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cr.mux.Handle( |
|
|
|
|
http.MethodGet, |
|
|
|
|
"/debug", |
|
|
|
|
func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { |
|
|
|
|
expvar.Handler().ServeHTTP(w, r) |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
return cr |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -47,10 +56,14 @@ func (cr *router) handle(method string, path string, handler jsonapi.Handler) {
|
|
|
|
|
method, |
|
|
|
|
path, |
|
|
|
|
func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { |
|
|
|
|
mp := make(map[string]string) |
|
|
|
|
var mp map[string]string |
|
|
|
|
|
|
|
|
|
if len(ps) > 0 { |
|
|
|
|
mp = make(map[string]string, len(ps)) |
|
|
|
|
|
|
|
|
|
for _, p := range ps { |
|
|
|
|
mp[p.Key] = p.Value |
|
|
|
|
for _, p := range ps { |
|
|
|
|
mp[p.Key] = p.Value |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handler.Serve(jsonapi.NewRequest(r, w, mp)) |
|
|
|
|