| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package main | 5 package main |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "net/http" | 8 "net/http" |
| 9 | 9 |
| 10 "github.com/julienschmidt/httprouter" | 10 "github.com/julienschmidt/httprouter" |
| 11 "github.com/luci/luci-go/appengine/gaemiddleware" | 11 "github.com/luci/luci-go/appengine/gaemiddleware" |
| 12 "github.com/luci/luci-go/appengine/logdog/coordinator" | 12 "github.com/luci/luci-go/appengine/logdog/coordinator" |
| 13 "github.com/luci/luci-go/appengine/logdog/coordinator/config" | 13 "github.com/luci/luci-go/appengine/logdog/coordinator/config" |
| 14 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/admin" | 14 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/admin" |
| 15 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/logs" | 15 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/logs" |
| 16 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/registra
tion" |
| 16 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/services
" | 17 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/services
" |
| 17 adminPb "github.com/luci/luci-go/common/api/logdog_coordinator/admin/v1" | 18 adminPb "github.com/luci/luci-go/common/api/logdog_coordinator/admin/v1" |
| 18 logsPb "github.com/luci/luci-go/common/api/logdog_coordinator/logs/v1" | 19 logsPb "github.com/luci/luci-go/common/api/logdog_coordinator/logs/v1" |
| 20 registrationPb "github.com/luci/luci-go/common/api/logdog_coordinator/re
gistration/v1" |
| 19 servicesPb "github.com/luci/luci-go/common/api/logdog_coordinator/servic
es/v1" | 21 servicesPb "github.com/luci/luci-go/common/api/logdog_coordinator/servic
es/v1" |
| 20 log "github.com/luci/luci-go/common/logging" | 22 log "github.com/luci/luci-go/common/logging" |
| 21 "github.com/luci/luci-go/server/discovery" | 23 "github.com/luci/luci-go/server/discovery" |
| 22 "github.com/luci/luci-go/server/middleware" | 24 "github.com/luci/luci-go/server/middleware" |
| 23 "github.com/luci/luci-go/server/prpc" | 25 "github.com/luci/luci-go/server/prpc" |
| 24 "golang.org/x/net/context" | 26 "golang.org/x/net/context" |
| 25 "google.golang.org/appengine" | 27 "google.golang.org/appengine" |
| 26 | 28 |
| 27 // Include mutations package so its Mutations will register with tumble
via | 29 // Include mutations package so its Mutations will register with tumble
via |
| 28 // init(). | 30 // init(). |
| 29 _ "github.com/luci/luci-go/appengine/logdog/coordinator/mutations" | 31 _ "github.com/luci/luci-go/appengine/logdog/coordinator/mutations" |
| 30 ) | 32 ) |
| 31 | 33 |
| 32 // base is the root of the middleware chain. | 34 // base is the root of the middleware chain. |
| 33 func base(h middleware.Handler) httprouter.Handle { | 35 func base(h middleware.Handler) httprouter.Handle { |
| 34 h = coordinator.WithProdServices(h) | 36 h = coordinator.WithProdServices(h) |
| 35 return gaemiddleware.BaseProd(h) | 37 return gaemiddleware.BaseProd(h) |
| 36 } | 38 } |
| 37 | 39 |
| 38 // Run installs and executes this site. | 40 // Run installs and executes this site. |
| 39 func main() { | 41 func main() { |
| 40 router := httprouter.New() | 42 router := httprouter.New() |
| 41 | 43 |
| 42 // Setup Cloud Endpoints. | 44 // Setup Cloud Endpoints. |
| 43 svr := prpc.Server{ | 45 svr := prpc.Server{ |
| 44 AccessControl: accessControl, | 46 AccessControl: accessControl, |
| 45 } | 47 } |
| 46 adminPb.RegisterAdminServer(&svr, admin.New()) | 48 adminPb.RegisterAdminServer(&svr, admin.New()) |
| 47 servicesPb.RegisterServicesServer(&svr, services.New()) | 49 servicesPb.RegisterServicesServer(&svr, services.New()) |
| 50 registrationPb.RegisterRegistrationServer(&svr, registration.New()) |
| 48 logsPb.RegisterLogsServer(&svr, logs.New()) | 51 logsPb.RegisterLogsServer(&svr, logs.New()) |
| 49 discovery.Enable(&svr) | 52 discovery.Enable(&svr) |
| 50 | 53 |
| 51 // Standard HTTP endpoints. | 54 // Standard HTTP endpoints. |
| 52 gaemiddleware.InstallHandlers(router, base) | 55 gaemiddleware.InstallHandlers(router, base) |
| 53 svr.InstallHandlers(router, base) | 56 svr.InstallHandlers(router, base) |
| 54 | 57 |
| 55 // Redirect "/" to "/app/". | 58 // Redirect "/" to "/app/". |
| 56 router.GET("/", func(w http.ResponseWriter, r *http.Request, ps httprout
er.Params) { | 59 router.GET("/", func(w http.ResponseWriter, r *http.Request, ps httprout
er.Params) { |
| 57 http.Redirect(w, r, "/app/", http.StatusFound) | 60 http.Redirect(w, r, "/app/", http.StatusFound) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 73 return false | 76 return false |
| 74 } | 77 } |
| 75 | 78 |
| 76 for _, o := range ccfg.RpcAllowOrigins { | 79 for _, o := range ccfg.RpcAllowOrigins { |
| 77 if o == origin { | 80 if o == origin { |
| 78 return true | 81 return true |
| 79 } | 82 } |
| 80 } | 83 } |
| 81 return false | 84 return false |
| 82 } | 85 } |
| OLD | NEW |