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

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: 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 unified diff | Download patch
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 » baseHandlers := settings.Base()
23 » r.GET("/", wrap(frontpage{})) 22
24 » r.GET("/swarming/:server/:id/steps/*logname", wrap(swarming.Log{})) 23 » gaemiddleware.InstallHandlers(r, baseHandlers)
25 » r.GET("/swarming/:server/:id", wrap(swarming.Build{})) 24 » r.GET("/", append(baseHandlers, settings.Wrap(frontpage{}))...)
25 » r.GET("/swarming/:server/:id/steps/*logname", append(baseHandlers, setti ngs.Wrap(swarming.Log{}))...)
26 » r.GET("/swarming/:server/:id", append(baseHandlers, settings.Wrap(swarmi ng.Build{}))...)
26 27
27 // Buildbot 28 // Buildbot
28 » r.GET("/buildbot/:master/:builder/:build", wrap(buildbot.Build{})) 29 » r.GET("/buildbot/:master/:builder/:build", append(baseHandlers, settings .Wrap(buildbot.Build{}))...)
29 » r.GET("/buildbot/:master/:builder/", wrap(buildbot.Builder{})) 30 » r.GET("/buildbot/:master/:builder/", append(baseHandlers, settings.Wrap( buildbot.Builder{}))...)
30 31
31 // User settings 32 // User settings
32 » r.GET("/settings", wrap(settings.Settings{})) 33 » r.GET("/settings", append(baseHandlers, settings.Wrap(settings.Settings{ }))...)
33 » r.POST("/settings", settings.Base(settings.ChangeSettings)) 34 » r.POST("/settings", append(baseHandlers, settings.ChangeSettings)...)
34 35
35 // PubSub subscription endpoints. 36 // PubSub subscription endpoints.
36 » r.POST("/pubsub/buildbot", settings.Base(buildbot.PubSubHandler)) 37 » r.POST("/pubsub/buildbot", append(baseHandlers, buildbot.PubSubHandler). ..)
37 38
38 http.Handle("/", r) 39 http.Handle("/", r)
39 } 40 }
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

Powered by Google App Engine
This is Rietveld 408576698