| 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" |
| 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), UpdateH
andler) |
| 43 » » settings.UpdateHandler) | 43 » r.GET("/admin/configs", basemw, ConfigsHandler) |
| 44 » r.GET("/admin/configs", basemw, settings.Wrap(settings.ViewConfigs{})) | |
| 45 | 44 |
| 46 // Console | 45 // Console |
| 47 » r.GET("/console/:project/:name", basemw, settings.Wrap(console.Console{}
)) | 46 » r.GET("/console/:project/:name", basemw, console.ConsoleHandler) |
| 48 r.GET("/console/:project", basemw, console.Main) | 47 r.GET("/console/:project", basemw, console.Main) |
| 49 | 48 |
| 50 // Swarming | 49 // Swarming |
| 51 » r.GET("/swarming/task/:id/steps/*logname", basemw, settings.Wrap(swarmin
g.Log{})) | 50 » r.GET("/swarming/task/:id/steps/*logname", basemw, swarming.LogHandler) |
| 52 » r.GET("/swarming/task/:id", basemw, settings.Wrap(swarming.Build{})) | 51 » r.GET("/swarming/task/:id", basemw, swarming.BuildHandler) |
| 53 » // Backward-compatible URLs: | 52 » // Backward-compatible URLs for Swarming: |
| 54 » r.GET("/swarming/prod/:id/steps/*logname", basemw, settings.Wrap(swarmin
g.Log{})) | 53 » r.GET("/swarming/prod/:id/steps/*logname", basemw, swarming.LogHandler) |
| 55 » r.GET("/swarming/prod/:id", basemw, settings.Wrap(swarming.Build{})) | 54 » r.GET("/swarming/prod/:id", basemw, swarming.BuildHandler) |
| 56 | 55 |
| 57 // Buildbucket | 56 // Buildbucket |
| 58 » r.GET("/buildbucket/:bucket/:builder", basemw, settings.Wrap(buildbucket
.Builder{})) | 57 » r.GET("/buildbucket/:bucket/:builder", basemw, buildbucket.BuilderHandle
r) |
| 59 | 58 |
| 60 // Buildbot | 59 // Buildbot |
| 61 » r.GET("/buildbot/:master/:builder/:build", basemw, settings.Wrap(buildbo
t.Build{})) | 60 » r.GET("/buildbot/:master/:builder/:build", basemw, buildbot.BuildHandler
) |
| 62 » r.GET("/buildbot/:master/:builder/", basemw, settings.Wrap(buildbot.Buil
der{})) | 61 » r.GET("/buildbot/:master/:builder/", basemw, buildbot.BuilderHandler) |
| 63 | 62 |
| 64 // LogDog Milo Annotation Streams. | 63 // LogDog Milo Annotation Streams. |
| 65 » r.GET("/logdog/build/:project/*path", basemw, settings.Wrap(&logdog.Anno
tationStreamHandler{})) | 64 » 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 | 65 |
| 71 // PubSub subscription endpoints. | 66 // PubSub subscription endpoints. |
| 72 r.POST("/pubsub/buildbot", basemw, buildbot.PubSubHandler) | 67 r.POST("/pubsub/buildbot", basemw, buildbot.PubSubHandler) |
| 73 | 68 |
| 74 // pRPC style endpoints. | 69 // pRPC style endpoints. |
| 75 api := prpc.Server{ | 70 api := prpc.Server{ |
| 76 UnaryServerInterceptor: grpcmon.NewUnaryServerInterceptor(nil), | 71 UnaryServerInterceptor: grpcmon.NewUnaryServerInterceptor(nil), |
| 77 } | 72 } |
| 78 milo.RegisterBuildbotServer(&api, &milo.DecoratedBuildbot{ | 73 milo.RegisterBuildbotServer(&api, &milo.DecoratedBuildbot{ |
| 79 Service: &buildbot.Service{}, | 74 Service: &buildbot.Service{}, |
| 80 Prelude: emptyPrelude, | 75 Prelude: emptyPrelude, |
| 81 }) | 76 }) |
| 82 milo.RegisterBuildInfoServer(&api, &milo.DecoratedBuildInfo{ | 77 milo.RegisterBuildInfoServer(&api, &milo.DecoratedBuildInfo{ |
| 83 Service: &buildinfo.Service{}, | 78 Service: &buildinfo.Service{}, |
| 84 Prelude: emptyPrelude, | 79 Prelude: emptyPrelude, |
| 85 }) | 80 }) |
| 86 discovery.Enable(&api) | 81 discovery.Enable(&api) |
| 87 api.InstallHandlers(r, gaemiddleware.BaseProd()) | 82 api.InstallHandlers(r, gaemiddleware.BaseProd()) |
| 88 | 83 |
| 89 http.DefaultServeMux.Handle("/", r) | 84 http.DefaultServeMux.Handle("/", r) |
| 90 } | 85 } |
| OLD | NEW |