| OLD | NEW |
| 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 } | |
| OLD | NEW |