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

Side by Side Diff: appengine/cmd/milo/frontend/milo.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/milo/buildbot/pubsub_test.go ('k') | appengine/cmd/milo/settings/settings.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 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 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 frontend 5 package frontend
6 6
7 import ( 7 import (
8 "net/http" 8 "net/http"
9 9
10 "github.com/julienschmidt/httprouter"
11
12 "github.com/luci/luci-go/appengine/cmd/milo/buildbot" 10 "github.com/luci/luci-go/appengine/cmd/milo/buildbot"
13 "github.com/luci/luci-go/appengine/cmd/milo/settings" 11 "github.com/luci/luci-go/appengine/cmd/milo/settings"
14 "github.com/luci/luci-go/appengine/cmd/milo/swarming" 12 "github.com/luci/luci-go/appengine/cmd/milo/swarming"
15 "github.com/luci/luci-go/appengine/gaemiddleware" 13 "github.com/luci/luci-go/appengine/gaemiddleware"
14 "github.com/luci/luci-go/server/router"
16 ) 15 )
17 16
18 // Where it all begins!!! 17 // Where it all begins!!!
19 func init() { 18 func init() {
20 // Register plain ol' http services. 19 // Register plain ol' http services.
21 » r := httprouter.New() 20 » r := router.New()
22 » gaemiddleware.InstallHandlers(r, settings.Base) 21 » basemw := settings.Base()
23 » r.GET("/", wrap(frontpage{})) 22 » gaemiddleware.InstallHandlers(r, basemw)
24 » r.GET("/swarming/:server/:id/steps/*logname", wrap(swarming.Log{})) 23 » r.GET("/", basemw, settings.Wrap(frontpage{}))
25 » r.GET("/swarming/:server/:id", wrap(swarming.Build{})) 24 » r.GET("/swarming/:server/:id/steps/*logname", basemw, settings.Wrap(swar ming.Log{}))
25 » r.GET("/swarming/:server/:id", basemw, settings.Wrap(swarming.Build{}))
26 26
27 // Buildbot 27 // Buildbot
28 » r.GET("/buildbot/:master/:builder/:build", wrap(buildbot.Build{})) 28 » r.GET("/buildbot/:master/:builder/:build", basemw, settings.Wrap(buildbo t.Build{}))
29 » r.GET("/buildbot/:master/:builder/", wrap(buildbot.Builder{})) 29 » r.GET("/buildbot/:master/:builder/", basemw, settings.Wrap(buildbot.Buil der{}))
30 30
31 // User settings 31 // User settings
32 » r.GET("/settings", wrap(settings.Settings{})) 32 » r.GET("/settings", basemw, settings.Wrap(settings.Settings{}))
33 » r.POST("/settings", settings.Base(settings.ChangeSettings)) 33 » r.POST("/settings", basemw, settings.ChangeSettings)
34 34
35 // PubSub subscription endpoints. 35 // PubSub subscription endpoints.
36 » r.POST("/pubsub/buildbot", settings.Base(buildbot.PubSubHandler)) 36 » r.POST("/pubsub/buildbot", basemw, buildbot.PubSubHandler)
37 37
38 http.Handle("/", r) 38 http.Handle("/", r)
39 } 39 }
40
41 // Do all the middleware initilization and theme handling.
42 func wrap(h settings.ThemedHandler) httprouter.Handle {
43 return settings.Wrap(h)
44 }
OLDNEW
« no previous file with comments | « appengine/cmd/milo/buildbot/pubsub_test.go ('k') | appengine/cmd/milo/settings/settings.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698