Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1903)

Unified Diff: appengine/gaemiddleware/context.go

Issue 2043423004: Make HTTP middleware easier to use (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Update tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/gaemiddleware/context.go
diff --git a/appengine/gaemiddleware/context.go b/appengine/gaemiddleware/context.go
index 60a8bce83791c2a309cd777a9bd2c7ade7e19373..b8da7cc1e39949972f6a8e418ddfb5ba121d76d2 100644
--- a/appengine/gaemiddleware/context.go
+++ b/appengine/gaemiddleware/context.go
@@ -9,7 +9,6 @@ import (
"google.golang.org/appengine"
- "github.com/julienschmidt/httprouter"
"golang.org/x/net/context"
"github.com/luci/gae/filter/dscache"
@@ -25,6 +24,7 @@ import (
"github.com/luci/luci-go/server/auth"
"github.com/luci/luci-go/server/middleware"
"github.com/luci/luci-go/server/proccache"
+ "github.com/luci/luci-go/server/router"
"github.com/luci/luci-go/server/settings"
)
@@ -78,12 +78,14 @@ func WithProd(c context.Context, req *http.Request) context.Context {
//
// It installs services using WithProd, installs a panic catcher if this
// is not a devserver, and injects the monitoring middleware.
-func BaseProd(h middleware.Handler) httprouter.Handle {
- h = globalTsMonState.Middleware(h)
+func BaseProd() []router.Handler {
+ var h []router.Handler
+ h = append(h, func(c *router.Context) {
+ c.Context = WithProd(context.Background(), c.Request)
+ })
if !appengine.IsDevAppServer() {
- h = middleware.WithPanicCatcher(h)
- }
- return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
- h(WithProd(context.Background(), r), rw, r, p)
+ h = append(h, middleware.WithPanicCatcher())
}
+ h = append(h, globalTsMonState.Middleware())
+ return h
}

Powered by Google App Engine
This is Rietveld 408576698