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/common" | |
19 "github.com/luci/luci-go/milo/appengine/frontend/console" | |
20 "github.com/luci/luci-go/milo/appengine/job_source/buildbot" | |
21 "github.com/luci/luci-go/milo/appengine/job_source/buildbucket" | |
22 "github.com/luci/luci-go/milo/appengine/job_source/raw_presentation" | |
23 "github.com/luci/luci-go/milo/appengine/job_source/swarming" | |
24 "github.com/luci/luci-go/milo/appengine/rpc" | |
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) | |
37 | |
38 basemw := common.Base("templates") | |
39 r.GET("/", basemw, frontpageHandler) | |
40 | |
41 // Admin and cron endpoints. | |
42 r.GET("/admin/update", basemw.Extend(gaemiddleware.RequireCron), UpdateC
onfigHandler) | |
43 r.GET("/admin/configs", basemw, ConfigsHandler) | |
44 | |
45 // Console | |
46 r.GET("/console/:project/:name", basemw, console.ConsoleHandler) | |
47 r.GET("/console/:project", basemw, console.Main) | |
48 | |
49 // Swarming | |
50 r.GET("/swarming/task/:id/steps/*logname", basemw, swarming.LogHandler) | |
51 r.GET("/swarming/task/:id", basemw, swarming.BuildHandler) | |
52 // Backward-compatible URLs for Swarming: | |
53 r.GET("/swarming/prod/:id/steps/*logname", basemw, swarming.LogHandler) | |
54 r.GET("/swarming/prod/:id", basemw, swarming.BuildHandler) | |
55 | |
56 // Buildbucket | |
57 r.GET("/buildbucket/:bucket/:builder", basemw, buildbucket.BuilderHandle
r) | |
58 | |
59 // Buildbot | |
60 r.GET("/buildbot/:master/:builder/:build", basemw, buildbot.BuildHandler
) | |
61 r.GET("/buildbot/:master/:builder/", basemw, buildbot.BuilderHandler) | |
62 | |
63 // LogDog Milo Annotation Streams. | |
64 // This mimicks the `logdog://logdog_host/project/*path` url scheme seen
on | |
65 // swarming tasks. | |
66 r.GET("/raw/build/:logdog_host/:project/*path", basemw, raw_presentation
.BuildHandler) | |
67 | |
68 // PubSub subscription endpoints. | |
69 r.POST("/_ah/push-handlers/buildbot", basemw, buildbot.PubSubHandler) | |
70 | |
71 // pRPC style endpoints. | |
72 api := prpc.Server{ | |
73 UnaryServerInterceptor: grpcmon.NewUnaryServerInterceptor(nil), | |
74 } | |
75 milo.RegisterBuildbotServer(&api, &milo.DecoratedBuildbot{ | |
76 Service: &buildbot.Service{}, | |
77 Prelude: emptyPrelude, | |
78 }) | |
79 milo.RegisterBuildInfoServer(&api, &milo.DecoratedBuildInfo{ | |
80 Service: &rpc.BuildInfoService{}, | |
81 Prelude: emptyPrelude, | |
82 }) | |
83 discovery.Enable(&api) | |
84 api.InstallHandlers(r, gaemiddleware.BaseProd()) | |
85 | |
86 http.DefaultServeMux.Handle("/", r) | |
87 } | |
OLD | NEW |