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

Unified Diff: appengine/cmd/dm/distributor/handlers.go

Issue 2043423004: Make HTTP middleware easier to use (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: gaemiddleware: add middleware func for WithProd 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
« no previous file with comments | « appengine/cmd/cron/ui/project.go ('k') | appengine/cmd/dm/distributor/pubsub.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/cmd/dm/distributor/handlers.go
diff --git a/appengine/cmd/dm/distributor/handlers.go b/appengine/cmd/dm/distributor/handlers.go
index e8efce4b5911ed780f89ee597df36187076c2fc0..098710c0d8f77b8c775cb9efb5fb1fb5279128ba 100644
--- a/appengine/cmd/dm/distributor/handlers.go
+++ b/appengine/cmd/dm/distributor/handlers.go
@@ -1,29 +1,25 @@
// Copyright 2016 The LUCI Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
package distributor
import (
- "net/http"
-
- "github.com/julienschmidt/httprouter"
"github.com/luci/luci-go/appengine/gaemiddleware"
- "github.com/luci/luci-go/server/middleware"
- "golang.org/x/net/context"
+ "github.com/luci/luci-go/server/router"
)
// InstallHandlers installs the taskqueue callback handler.
//
// The `base` middleware must have a registry installed with WithRegistry.
-func InstallHandlers(reg Registry, r *httprouter.Router, base middleware.Base) {
- r.POST(handlerPattern, base(
- gaemiddleware.RequireTaskQueue("", func(c context.Context, rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
- TaskQueueHandler(WithRegistry(c, reg), rw, r, p)
- })))
+func InstallHandlers(reg Registry, r *router.Router, base router.MiddlewareChain) {
+ r.POST(handlerPattern, append(base, gaemiddleware.RequireTaskQueue(""), func(c *router.Context, next router.Handler) {
+ c.Context = WithRegistry(c.Context, reg)
+ next(c)
+ }), TaskQueueHandler)
- r.POST("/_ah/push-handlers/"+notifyTopicSuffix, base(
- func(c context.Context, rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
- PubsubReciever(WithRegistry(c, reg), rw, r, p)
- }))
+ r.POST("/_ah/push-handlers/"+notifyTopicSuffix, append(base, func(c *router.Context, next router.Handler) {
+ c.Context = WithRegistry(c.Context, reg)
+ next(c)
+ }), PubsubReceiver)
}
« no previous file with comments | « appengine/cmd/cron/ui/project.go ('k') | appengine/cmd/dm/distributor/pubsub.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698