| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 // that can be found in the LICENSE file. | |
| 4 | |
| 5 package frontend | |
| 6 | |
| 7 import ( | |
| 8 "net/http" | |
| 9 | |
| 10 "github.com/golang/protobuf/proto" | |
| 11 "golang.org/x/net/context" | |
| 12 | |
| 13 "github.com/luci/luci-go/appengine/gaemiddleware" | |
| 14 "github.com/luci/luci-go/grpc/discovery" | |
| 15 "github.com/luci/luci-go/grpc/grpcmon" | |
| 16 "github.com/luci/luci-go/grpc/prpc" | |
| 17 milo "github.com/luci/luci-go/milo/api/proto" | |
| 18 "github.com/luci/luci-go/milo/appengine/buildbot" | |
| 19 "github.com/luci/luci-go/milo/appengine/buildbucket" | |
| 20 "github.com/luci/luci-go/milo/appengine/buildinfo" | |
| 21 "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/settings" | |
| 24 "github.com/luci/luci-go/milo/appengine/swarming" | |
| 25 "github.com/luci/luci-go/server/router" | |
| 26 ) | |
| 27 | |
| 28 func emptyPrelude(c context.Context, methodName string, req proto.Message) (cont
ext.Context, error) { | |
| 29 return c, nil | |
| 30 } | |
| 31 | |
| 32 // Where it all begins!!! | |
| 33 func init() { | |
| 34 // Register plain ol' http handlers. | |
| 35 r := router.New() | |
| 36 gaemiddleware.InstallHandlers(r, gaemiddleware.BaseProd()) | |
| 37 | |
| 38 basemw := settings.Base() | |
| 39 r.GET("/", basemw, settings.Wrap(frontpage{})) | |
| 40 | |
| 41 // Admin and cron endpoints. | |
| 42 r.GET("/admin/update", basemw.Extend(gaemiddleware.RequireCron), | |
| 43 settings.UpdateHandler) | |
| 44 r.GET("/admin/configs", basemw, settings.Wrap(settings.ViewConfigs{})) | |
| 45 | |
| 46 // Console | |
| 47 r.GET("/console/:project/:name", basemw, settings.Wrap(console.Console{}
)) | |
| 48 r.GET("/console/:project", basemw, console.Main) | |
| 49 | |
| 50 // Swarming | |
| 51 r.GET("/swarming/task/:id/steps/*logname", basemw, settings.Wrap(swarmin
g.Log{})) | |
| 52 r.GET("/swarming/task/:id", basemw, settings.Wrap(swarming.Build{})) | |
| 53 // Backward-compatible URLs: | |
| 54 r.GET("/swarming/prod/:id/steps/*logname", basemw, settings.Wrap(swarmin
g.Log{})) | |
| 55 r.GET("/swarming/prod/:id", basemw, settings.Wrap(swarming.Build{})) | |
| 56 | |
| 57 // Buildbucket | |
| 58 r.GET("/buildbucket/:bucket/:builder", basemw, settings.Wrap(buildbucket
.Builder{})) | |
| 59 | |
| 60 // Buildbot | |
| 61 r.GET("/buildbot/:master/:builder/:build", basemw, settings.Wrap(buildbo
t.Build{})) | |
| 62 r.GET("/buildbot/:master/:builder/", basemw, settings.Wrap(buildbot.Buil
der{})) | |
| 63 | |
| 64 // LogDog Milo Annotation Streams. | |
| 65 r.GET("/logdog/build/:project/*path", basemw, settings.Wrap(&logdog.Anno
tationStreamHandler{})) | |
| 66 | |
| 67 // User settings | |
| 68 r.GET("/settings", basemw, settings.Wrap(settings.Settings{})) | |
| 69 r.POST("/settings", basemw, settings.ChangeSettings) | |
| 70 | |
| 71 // PubSub subscription endpoints. | |
| 72 r.POST("/pubsub/buildbot", basemw, buildbot.PubSubHandler) | |
| 73 | |
| 74 // pRPC style endpoints. | |
| 75 api := prpc.Server{ | |
| 76 UnaryServerInterceptor: grpcmon.NewUnaryServerInterceptor(nil), | |
| 77 } | |
| 78 milo.RegisterBuildbotServer(&api, &milo.DecoratedBuildbot{ | |
| 79 Service: &buildbot.Service{}, | |
| 80 Prelude: emptyPrelude, | |
| 81 }) | |
| 82 milo.RegisterBuildInfoServer(&api, &milo.DecoratedBuildInfo{ | |
| 83 Service: &buildinfo.Service{}, | |
| 84 Prelude: emptyPrelude, | |
| 85 }) | |
| 86 discovery.Enable(&api) | |
| 87 api.InstallHandlers(r, gaemiddleware.BaseProd()) | |
| 88 | |
| 89 http.DefaultServeMux.Handle("/", r) | |
| 90 } | |
| OLD | NEW |