Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
|
nodir
2017/03/17 20:47:58
file name milo is abstract, while the contents are
hinoka
2017/03/17 22:04:55
Done.
Actually i'll rename this main.go, since it
| |
| 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" |
| 11 "golang.org/x/net/context" | 11 "golang.org/x/net/context" |
| 12 | 12 |
| 13 "github.com/luci/luci-go/appengine/gaemiddleware" | 13 "github.com/luci/luci-go/appengine/gaemiddleware" |
| 14 "github.com/luci/luci-go/grpc/discovery" | 14 "github.com/luci/luci-go/grpc/discovery" |
| 15 "github.com/luci/luci-go/grpc/grpcmon" | 15 "github.com/luci/luci-go/grpc/grpcmon" |
| 16 "github.com/luci/luci-go/grpc/prpc" | 16 "github.com/luci/luci-go/grpc/prpc" |
| 17 milo "github.com/luci/luci-go/milo/api/proto" | 17 milo "github.com/luci/luci-go/milo/api/proto" |
| 18 "github.com/luci/luci-go/milo/appengine/buildbot" | 18 "github.com/luci/luci-go/milo/appengine/buildbot" |
| 19 "github.com/luci/luci-go/milo/appengine/buildbucket" | 19 "github.com/luci/luci-go/milo/appengine/buildbucket" |
| 20 "github.com/luci/luci-go/milo/appengine/buildinfo" | 20 "github.com/luci/luci-go/milo/appengine/buildinfo" |
| 21 "github.com/luci/luci-go/milo/appengine/common" | |
| 21 "github.com/luci/luci-go/milo/appengine/console" | 22 "github.com/luci/luci-go/milo/appengine/console" |
| 22 "github.com/luci/luci-go/milo/appengine/logdog" | 23 "github.com/luci/luci-go/milo/appengine/logdog" |
| 23 "github.com/luci/luci-go/milo/appengine/settings" | |
| 24 "github.com/luci/luci-go/milo/appengine/swarming" | 24 "github.com/luci/luci-go/milo/appengine/swarming" |
| 25 "github.com/luci/luci-go/server/router" | 25 "github.com/luci/luci-go/server/router" |
| 26 ) | 26 ) |
| 27 | 27 |
| 28 func emptyPrelude(c context.Context, methodName string, req proto.Message) (cont ext.Context, error) { | 28 func emptyPrelude(c context.Context, methodName string, req proto.Message) (cont ext.Context, error) { |
| 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 := common.Base() |
| 39 » r.GET("/", basemw, settings.Wrap(frontpage{})) | 39 » r.GET("/", basemw, frontpageHandler) |
| 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 » » common.UpdateHandler) |
|
nodir
2017/03/17 20:47:58
why UpdateHandler is in common package?
hinoka
2017/03/17 22:04:55
Moved
| |
| 44 » r.GET("/admin/configs", basemw, settings.Wrap(settings.ViewConfigs{})) | 44 » r.GET("/admin/configs", basemw, common.ConfigsHandler) |
| 45 | 45 |
| 46 // Console | 46 // Console |
| 47 » r.GET("/console/:project/:name", basemw, settings.Wrap(console.Console{} )) | 47 » r.GET("/console/:project/:name", basemw, console.ConsoleHandler) |
| 48 r.GET("/console/:project", basemw, console.Main) | 48 r.GET("/console/:project", basemw, console.Main) |
| 49 | 49 |
| 50 // Swarming | 50 // Swarming |
| 51 » r.GET("/swarming/task/:id/steps/*logname", basemw, settings.Wrap(swarmin g.Log{})) | 51 » r.GET("/swarming/task/:id/steps/*logname", basemw, swarming.LogHandler) |
| 52 » r.GET("/swarming/task/:id", basemw, settings.Wrap(swarming.Build{})) | 52 » r.GET("/swarming/task/:id", basemw, swarming.BuildHandler) |
| 53 » // Backward-compatible URLs: | 53 » // Backward-compatible URLs for Swarming: |
| 54 » r.GET("/swarming/prod/:id/steps/*logname", basemw, settings.Wrap(swarmin g.Log{})) | 54 » r.GET("/swarming/prod/:id/steps/*logname", basemw, swarming.LogHandler) |
| 55 » r.GET("/swarming/prod/:id", basemw, settings.Wrap(swarming.Build{})) | 55 » r.GET("/swarming/prod/:id", basemw, swarming.BuildHandler) |
| 56 | 56 |
| 57 // Buildbucket | 57 // Buildbucket |
| 58 » r.GET("/buildbucket/:bucket/:builder", basemw, settings.Wrap(buildbucket .Builder{})) | 58 » r.GET("/buildbucket/:bucket/:builder", basemw, buildbucket.BuilderHandle r) |
| 59 | 59 |
| 60 // Buildbot | 60 // Buildbot |
| 61 » r.GET("/buildbot/:master/:builder/:build", basemw, settings.Wrap(buildbo t.Build{})) | 61 » r.GET("/buildbot/:master/:builder/:build", basemw, buildbot.BuildHandler ) |
| 62 » r.GET("/buildbot/:master/:builder/", basemw, settings.Wrap(buildbot.Buil der{})) | 62 » r.GET("/buildbot/:master/:builder/", basemw, buildbot.BuilderHandler) |
| 63 | 63 |
| 64 // LogDog Milo Annotation Streams. | 64 // LogDog Milo Annotation Streams. |
| 65 » r.GET("/logdog/build/:project/*path", basemw, settings.Wrap(&logdog.Anno tationStreamHandler{})) | 65 » r.GET("/logdog/build/:project/*prefix", basemw, logdog.BuildHandler) |
| 66 | |
| 67 » // User settings | |
| 68 » r.GET("/settings", basemw, settings.Wrap(settings.Settings{})) | |
| 69 » r.POST("/settings", basemw, settings.ChangeSettings) | |
| 70 | 66 |
| 71 // PubSub subscription endpoints. | 67 // PubSub subscription endpoints. |
| 72 r.POST("/pubsub/buildbot", basemw, buildbot.PubSubHandler) | 68 r.POST("/pubsub/buildbot", basemw, buildbot.PubSubHandler) |
| 73 | 69 |
| 74 // pRPC style endpoints. | 70 // pRPC style endpoints. |
| 75 api := prpc.Server{ | 71 api := prpc.Server{ |
| 76 UnaryServerInterceptor: grpcmon.NewUnaryServerInterceptor(nil), | 72 UnaryServerInterceptor: grpcmon.NewUnaryServerInterceptor(nil), |
| 77 } | 73 } |
| 78 milo.RegisterBuildbotServer(&api, &milo.DecoratedBuildbot{ | 74 milo.RegisterBuildbotServer(&api, &milo.DecoratedBuildbot{ |
| 79 Service: &buildbot.Service{}, | 75 Service: &buildbot.Service{}, |
| 80 Prelude: emptyPrelude, | 76 Prelude: emptyPrelude, |
| 81 }) | 77 }) |
| 82 milo.RegisterBuildInfoServer(&api, &milo.DecoratedBuildInfo{ | 78 milo.RegisterBuildInfoServer(&api, &milo.DecoratedBuildInfo{ |
| 83 Service: &buildinfo.Service{}, | 79 Service: &buildinfo.Service{}, |
| 84 Prelude: emptyPrelude, | 80 Prelude: emptyPrelude, |
| 85 }) | 81 }) |
| 86 discovery.Enable(&api) | 82 discovery.Enable(&api) |
| 87 api.InstallHandlers(r, gaemiddleware.BaseProd()) | 83 api.InstallHandlers(r, gaemiddleware.BaseProd()) |
| 88 | 84 |
| 89 http.DefaultServeMux.Handle("/", r) | 85 http.DefaultServeMux.Handle("/", r) |
| 90 } | 86 } |
| OLD | NEW |