func WrapHandler(handler HandlerFunc) httprouter.Handle { return func(w http.ResponseWriter, req *http.Request, params httprouter.Params) { ctx := contextFromResponseWriter(w) ctx = ctxhelper.NewContextParams(ctx, params) handler.ServeHTTP(ctx, w, req) } }
func (api *API) WrapHandler(handler httphelper.HandlerFunc) httprouter.Handle { return func(w http.ResponseWriter, req *http.Request, params httprouter.Params) { ctx := w.(*httphelper.ResponseWriter).Context() log, _ := ctxhelper.LoggerFromContext(ctx) ctx = ctxhelper.NewContextParams(ctx, params) s, err := api.conf.SessionStore.Get(req, "session") if err != nil { log.Error(err.Error()) } ctx = context.WithValue(ctx, ctxSessionKey, s) handler.ServeHTTP(ctx, w, req) } }