Chromium Code Reviews| Index: appengine/cmd/cron/ui/common.go |
| diff --git a/appengine/cmd/cron/ui/common.go b/appengine/cmd/cron/ui/common.go |
| index 4e21ca07d7957556f9da77dd089fd1617bdc12f5..456ebf8bf1efddbc3bbcfb80cd9a3d2608b70009 100644 |
| --- a/appengine/cmd/cron/ui/common.go |
| +++ b/appengine/cmd/cron/ui/common.go |
| @@ -8,7 +8,6 @@ package ui |
| import ( |
| "strings" |
| - "github.com/julienschmidt/httprouter" |
| "golang.org/x/net/context" |
| "google.golang.org/appengine" |
| @@ -16,7 +15,7 @@ import ( |
| "github.com/luci/luci-go/server/auth" |
| "github.com/luci/luci-go/server/auth/xsrf" |
| - "github.com/luci/luci-go/server/middleware" |
| + "github.com/luci/luci-go/server/router" |
| "github.com/luci/luci-go/server/templates" |
| "github.com/luci/luci-go/appengine/cmd/cron/engine" |
| @@ -29,26 +28,28 @@ type Config struct { |
| } |
| // InstallHandlers adds HTTP handlers that render HTML pages. |
| -func InstallHandlers(r *httprouter.Router, base middleware.Base, cfg Config) { |
| +func InstallHandlers(r *router.Router, handlers []router.Handler, cfg Config) { |
| tmpl := prepareTemplates(cfg.TemplatesPath) |
| - wrap := func(h middleware.Handler) httprouter.Handle { |
| - h = auth.Authenticate(h) |
| - h = templates.WithTemplates(h, tmpl) |
| - h = middleware.WithContextValue(h, configContextKey(0), &cfg) |
| - return base(h) |
| + wrap := func() []router.Handler { |
| + return append( |
| + handlers, |
| + router.HandlerWithContextValue(configContextKey(0), &cfg), |
| + templates.WithTemplates(tmpl), |
| + auth.Authenticate(), |
| + ) |
| } |
| - r.GET("/", wrap(indexPage)) |
| - r.GET("/jobs/:ProjectID", wrap(projectPage)) |
| - r.GET("/jobs/:ProjectID/:JobID", wrap(jobPage)) |
| - r.GET("/jobs/:ProjectID/:JobID/:InvID", wrap(invocationPage)) |
| + r.GET("/", append(wrap(), indexPage)...) |
| + r.GET("/jobs/:ProjectID", append(wrap(), projectPage)...) |
| + r.GET("/jobs/:ProjectID/:JobID", append(wrap(), jobPage)...) |
| + r.GET("/jobs/:ProjectID/:JobID/:InvID", append(wrap(), invocationPage)...) |
|
iannucci
2016/06/13 19:23:28
same here?
|
| // All POST forms must be protected with XSRF token. |
| - r.POST("/actions/runJob/:ProjectID/:JobID", wrap(xsrf.WithTokenCheck(runJobAction))) |
| - r.POST("/actions/pauseJob/:ProjectID/:JobID", wrap(xsrf.WithTokenCheck(pauseJobAction))) |
| - r.POST("/actions/resumeJob/:ProjectID/:JobID", wrap(xsrf.WithTokenCheck(resumeJobAction))) |
| - r.POST("/actions/abortInvocation/:ProjectID/:JobID/:InvID", wrap(xsrf.WithTokenCheck(abortInvocationAction))) |
| + r.POST("/actions/runJob/:ProjectID/:JobID", append(wrap(), xsrf.WithTokenCheck(), runJobAction)...) |
| + r.POST("/actions/pauseJob/:ProjectID/:JobID", append(wrap(), xsrf.WithTokenCheck(), pauseJobAction)...) |
| + r.POST("/actions/resumeJob/:ProjectID/:JobID", append(wrap(), xsrf.WithTokenCheck(), resumeJobAction)...) |
| + r.POST("/actions/abortInvocation/:ProjectID/:JobID/:InvID", append(wrap(), xsrf.WithTokenCheck(), abortInvocationAction)...) |
| } |
| type configContextKey int |