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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package distributor 5 package distributor
6 6
7 import ( 7 import (
8 "net/http"
9
10 "github.com/julienschmidt/httprouter"
11 "github.com/luci/luci-go/appengine/gaemiddleware" 8 "github.com/luci/luci-go/appengine/gaemiddleware"
12 » "github.com/luci/luci-go/server/middleware" 9 » "github.com/luci/luci-go/server/router"
13 » "golang.org/x/net/context"
14 ) 10 )
15 11
16 // InstallHandlers installs the taskqueue callback handler. 12 // InstallHandlers installs the taskqueue callback handler.
17 // 13 //
18 // The `base` middleware must have a registry installed with WithRegistry. 14 // The `base` middleware must have a registry installed with WithRegistry.
19 func InstallHandlers(reg Registry, r *httprouter.Router, base middleware.Base) { 15 func InstallHandlers(reg Registry, r *router.Router, base router.MiddlewareChain ) {
20 » r.POST(handlerPattern, base( 16 » r.POST(handlerPattern, append(base, gaemiddleware.RequireTaskQueue(""), func(c *router.Context, next router.Handler) {
21 » » gaemiddleware.RequireTaskQueue("", func(c context.Context, rw ht tp.ResponseWriter, r *http.Request, p httprouter.Params) { 17 » » c.Context = WithRegistry(c.Context, reg)
22 » » » TaskQueueHandler(WithRegistry(c, reg), rw, r, p) 18 » » next(c)
23 » » }))) 19 » }), TaskQueueHandler)
24 20
25 » r.POST("/_ah/push-handlers/"+notifyTopicSuffix, base( 21 » r.POST("/_ah/push-handlers/"+notifyTopicSuffix, append(base, func(c *rou ter.Context, next router.Handler) {
26 » » func(c context.Context, rw http.ResponseWriter, r *http.Request, p httprouter.Params) { 22 » » c.Context = WithRegistry(c.Context, reg)
27 » » » PubsubReciever(WithRegistry(c, reg), rw, r, p) 23 » » next(c)
28 » » })) 24 » }), PubsubReceiver)
29 } 25 }
OLDNEW
« 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