Chromium Code Reviews| 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/golang/protobuf/proto" | 10 "github.com/golang/protobuf/proto" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 return c, nil | 29 return c, nil |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Where it all begins!!! | 32 // Where it all begins!!! |
| 33 func init() { | 33 func init() { |
| 34 // Register plain ol' http handlers. | 34 // Register plain ol' http handlers. |
| 35 r := router.New() | 35 r := router.New() |
| 36 gaemiddleware.InstallHandlers(r, gaemiddleware.BaseProd()) | 36 gaemiddleware.InstallHandlers(r, gaemiddleware.BaseProd()) |
| 37 | 37 |
| 38 basemw := settings.Base() | 38 basemw := settings.Base() |
| 39 » r.GET("/", basemw, settings.Wrap(frontpage{})) | 39 » r.GET("/", basemw, settings.Wrap(frontpageHandler, "frontpage.html")) |
|
nodir
2017/03/16 17:42:51
i don't see a reason to decouple handler functions
hinoka
2017/03/17 20:00:21
Done.
| |
| 40 | 40 |
| 41 // Admin and cron endpoints. | 41 // Admin and cron endpoints. |
| 42 r.GET("/admin/update", basemw.Extend(gaemiddleware.RequireCron), | 42 r.GET("/admin/update", basemw.Extend(gaemiddleware.RequireCron), |
| 43 settings.UpdateHandler) | 43 settings.UpdateHandler) |
| 44 » r.GET("/admin/configs", basemw, settings.Wrap(settings.ViewConfigs{})) | 44 » r.GET("/admin/configs", basemw, |
| 45 » » settings.Wrap(settings.ConfigsHandler, "configs.html")) | |
| 45 | 46 |
| 46 // Console | 47 // Console |
| 47 » r.GET("/console/:project/:name", basemw, settings.Wrap(console.Console{} )) | 48 » r.GET("/console/:project/:name", basemw, |
| 49 » » settings.Wrap(console.ConsoleHandler, "console.html")) | |
| 48 r.GET("/console/:project", basemw, console.Main) | 50 r.GET("/console/:project", basemw, console.Main) |
| 49 | 51 |
| 50 // Swarming | 52 // Swarming |
| 51 » r.GET("/swarming/task/:id/steps/*logname", basemw, settings.Wrap(swarmin g.Log{})) | 53 » r.GET("/swarming/task/:id/steps/*logname", basemw, |
| 52 » r.GET("/swarming/task/:id", basemw, settings.Wrap(swarming.Build{})) | 54 » » settings.Wrap(swarming.LogHandler, "log.html")) |
| 53 » // Backward-compatible URLs: | 55 » r.GET("/swarming/task/:id", basemw, settings.Wrap( |
| 54 » r.GET("/swarming/prod/:id/steps/*logname", basemw, settings.Wrap(swarmin g.Log{})) | 56 » » swarming.BuildHandler, "build.html")) |
| 55 » r.GET("/swarming/prod/:id", basemw, settings.Wrap(swarming.Build{})) | 57 » // Backward-compatible URLs for Swarming: |
| 58 » r.GET("/swarming/prod/:id/steps/*logname", basemw, | |
| 59 » » settings.Wrap(swarming.LogHandler, "log.html")) | |
| 60 » r.GET("/swarming/prod/:id", basemw, | |
| 61 » » settings.Wrap(swarming.BuildHandler, "build.html")) | |
| 56 | 62 |
| 57 // Buildbucket | 63 // Buildbucket |
| 58 » r.GET("/buildbucket/:bucket/:builder", basemw, settings.Wrap(buildbucket .Builder{})) | 64 » r.GET("/buildbucket/:bucket/:builder", basemw, |
| 65 » » settings.Wrap(buildbucket.BuilderHandler, "builder.html")) | |
| 59 | 66 |
| 60 // Buildbot | 67 // Buildbot |
| 61 » r.GET("/buildbot/:master/:builder/:build", basemw, settings.Wrap(buildbo t.Build{})) | 68 » r.GET("/buildbot/:master/:builder/:build", basemw, |
| 62 » r.GET("/buildbot/:master/:builder/", basemw, settings.Wrap(buildbot.Buil der{})) | 69 » » settings.Wrap(buildbot.BuildHandler, "build.html")) |
| 70 » r.GET("/buildbot/:master/:builder/", basemw, | |
| 71 » » settings.Wrap(buildbot.BuilderHandler, "builder.html")) | |
| 63 | 72 |
| 64 // LogDog Milo Annotation Streams. | 73 // LogDog Milo Annotation Streams. |
| 65 » r.GET("/logdog/build/:project/*path", basemw, settings.Wrap(&logdog.Anno tationStreamHandler{})) | 74 » r.GET("/logdog/build/:project/*prefix", basemw, |
| 66 | 75 » » settings.Wrap(logdog.BuildHandler, "build.html")) |
| 67 » // User settings | |
| 68 » r.GET("/settings", basemw, settings.Wrap(settings.Settings{})) | |
| 69 » r.POST("/settings", basemw, settings.ChangeSettings) | |
| 70 | 76 |
| 71 // PubSub subscription endpoints. | 77 // PubSub subscription endpoints. |
| 72 r.POST("/pubsub/buildbot", basemw, buildbot.PubSubHandler) | 78 r.POST("/pubsub/buildbot", basemw, buildbot.PubSubHandler) |
| 73 | 79 |
| 74 // pRPC style endpoints. | 80 // pRPC style endpoints. |
| 75 api := prpc.Server{ | 81 api := prpc.Server{ |
| 76 UnaryServerInterceptor: grpcmon.NewUnaryServerInterceptor(nil), | 82 UnaryServerInterceptor: grpcmon.NewUnaryServerInterceptor(nil), |
| 77 } | 83 } |
| 78 milo.RegisterBuildbotServer(&api, &milo.DecoratedBuildbot{ | 84 milo.RegisterBuildbotServer(&api, &milo.DecoratedBuildbot{ |
| 79 Service: &buildbot.Service{}, | 85 Service: &buildbot.Service{}, |
| 80 Prelude: emptyPrelude, | 86 Prelude: emptyPrelude, |
| 81 }) | 87 }) |
| 82 milo.RegisterBuildInfoServer(&api, &milo.DecoratedBuildInfo{ | 88 milo.RegisterBuildInfoServer(&api, &milo.DecoratedBuildInfo{ |
| 83 Service: &buildinfo.Service{}, | 89 Service: &buildinfo.Service{}, |
| 84 Prelude: emptyPrelude, | 90 Prelude: emptyPrelude, |
| 85 }) | 91 }) |
| 86 discovery.Enable(&api) | 92 discovery.Enable(&api) |
| 87 api.InstallHandlers(r, gaemiddleware.BaseProd()) | 93 api.InstallHandlers(r, gaemiddleware.BaseProd()) |
| 88 | 94 |
| 89 http.DefaultServeMux.Handle("/", r) | 95 http.DefaultServeMux.Handle("/", r) |
| 90 } | 96 } |
| OLD | NEW |