Got it working!

This commit is contained in:
Daniel Ledda
2020-11-02 23:58:12 +01:00
parent 10523274b8
commit 856e8723aa

View File

@@ -67,13 +67,14 @@ var MainRouter = Router{make(map[string] *PatternRouter)}
func getPatternHandler(pattern string) http.HandlerFunc { func getPatternHandler(pattern string) http.HandlerFunc {
return func (w http.ResponseWriter, r *http.Request) { return func (w http.ResponseWriter, r *http.Request) {
cb, err := MainRouter.MethodFuncForPattern(HttpMethod(r.Method), pattern) cb, err := MainRouter.MethodFuncForPattern(HttpMethod(r.Method), pattern)
context := RequestContext{w, r, HttpMethod(r.Method), pattern}
if err == nil { if err == nil {
err = cb(w, r) err = cb(w, r)
} }
if err != nil { if err != nil {
context := RequestContext{w, r, HttpMethod(r.Method), pattern}
sendInternalError(err, context) sendInternalError(err, context)
} }
fmt.Println(context)
} }
} }