OLD | NEW |
| (Empty) |
1 // Copyright 2015 The LUCI Authors. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 package frontend | |
16 | |
17 import ( | |
18 "net/http" | |
19 | |
20 "github.com/golang/protobuf/proto" | |
21 "golang.org/x/net/context" | |
22 | |
23 "github.com/luci/luci-go/appengine/gaemiddleware" | |
24 "github.com/luci/luci-go/grpc/discovery" | |
25 "github.com/luci/luci-go/grpc/grpcmon" | |
26 "github.com/luci/luci-go/grpc/prpc" | |
27 milo "github.com/luci/luci-go/milo/api/proto" | |
28 "github.com/luci/luci-go/milo/buildsource/buildbot" | |
29 "github.com/luci/luci-go/milo/buildsource/buildbucket" | |
30 "github.com/luci/luci-go/milo/buildsource/rawpresentation" | |
31 "github.com/luci/luci-go/milo/buildsource/swarming" | |
32 "github.com/luci/luci-go/milo/common" | |
33 "github.com/luci/luci-go/milo/frontend/console" | |
34 "github.com/luci/luci-go/milo/rpc" | |
35 "github.com/luci/luci-go/server/router" | |
36 ) | |
37 | |
38 func emptyPrelude(c context.Context, methodName string, req proto.Message) (cont
ext.Context, error) { | |
39 return c, nil | |
40 } | |
41 | |
42 // Run sets up all the routes and runs the server. | |
43 func Run(templatePath string) { | |
44 // Register plain ol' http handlers. | |
45 r := router.New() | |
46 gaemiddleware.InstallHandlers(r) | |
47 | |
48 basemw := common.Base(templatePath) | |
49 r.GET("/", basemw, frontpageHandler) | |
50 | |
51 // Admin and cron endpoints. | |
52 r.GET("/admin/update", basemw.Extend(gaemiddleware.RequireCron), UpdateC
onfigHandler) | |
53 r.GET("/admin/configs", basemw, ConfigsHandler) | |
54 | |
55 // Console | |
56 r.GET("/console/:project/:name", basemw, console.ConsoleHandler) | |
57 r.GET("/console/:project", basemw, console.Main) | |
58 | |
59 // Swarming | |
60 r.GET(swarming.URLBase+"/:id/steps/*logname", basemw, swarming.LogHandle
r) | |
61 r.GET(swarming.URLBase+"/:id", basemw, swarming.BuildHandler) | |
62 // Backward-compatible URLs for Swarming: | |
63 r.GET("/swarming/prod/:id/steps/*logname", basemw, swarming.LogHandler) | |
64 r.GET("/swarming/prod/:id", basemw, swarming.BuildHandler) | |
65 | |
66 // Buildbucket | |
67 r.GET("/buildbucket/:bucket/:builder", basemw, buildbucket.BuilderHandle
r) | |
68 | |
69 // Buildbot | |
70 r.GET("/buildbot/:master/:builder/:build", basemw, buildbot.BuildHandler
) | |
71 r.GET("/buildbot/:master/:builder/", basemw, buildbot.BuilderHandler) | |
72 | |
73 // LogDog Milo Annotation Streams. | |
74 // This mimicks the `logdog://logdog_host/project/*path` url scheme seen
on | |
75 // swarming tasks. | |
76 r.GET("/raw/build/:logdog_host/:project/*path", basemw, rawpresentation.
BuildHandler) | |
77 | |
78 // PubSub subscription endpoints. | |
79 r.POST("/_ah/push-handlers/buildbot", basemw, buildbot.PubSubHandler) | |
80 r.POST("/_ah/push-handlers/buildbucket", basemw, buildbucket.PubSubHandl
er) | |
81 | |
82 // pRPC style endpoints. | |
83 api := prpc.Server{ | |
84 UnaryServerInterceptor: grpcmon.NewUnaryServerInterceptor(nil), | |
85 } | |
86 milo.RegisterBuildbotServer(&api, &milo.DecoratedBuildbot{ | |
87 Service: &buildbot.Service{}, | |
88 Prelude: emptyPrelude, | |
89 }) | |
90 milo.RegisterBuildInfoServer(&api, &milo.DecoratedBuildInfo{ | |
91 Service: &rpc.BuildInfoService{}, | |
92 Prelude: emptyPrelude, | |
93 }) | |
94 discovery.Enable(&api) | |
95 api.InstallHandlers(r, gaemiddleware.BaseProd()) | |
96 | |
97 http.DefaultServeMux.Handle("/", r) | |
98 } | |
OLD | NEW |