| Index: appengine/cmd/logdog_coordinator/vmuser/main.go
|
| diff --git a/appengine/cmd/logdog_coordinator/vmuser/main.go b/appengine/cmd/logdog_coordinator/vmuser/main.go
|
| index b407c7e3fa25d9c919fade05b81d7504eca2c489..733af11f52e63d20f55511e0e2514fa354f81407 100644
|
| --- a/appengine/cmd/logdog_coordinator/vmuser/main.go
|
| +++ b/appengine/cmd/logdog_coordinator/vmuser/main.go
|
| @@ -1,78 +1,75 @@
|
| // Copyright 2015 The LUCI Authors. All rights reserved.
|
| // Use of this source code is governed under the Apache License, Version 2.0
|
| // that can be found in the LICENSE file.
|
|
|
| package main
|
|
|
| import (
|
| "net/http"
|
|
|
| - "github.com/julienschmidt/httprouter"
|
| "github.com/luci/luci-go/appengine/gaemiddleware"
|
| "github.com/luci/luci-go/appengine/logdog/coordinator"
|
| "github.com/luci/luci-go/appengine/logdog/coordinator/config"
|
| "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/admin"
|
| "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/logs"
|
| "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/registration"
|
| "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/services"
|
| adminPb "github.com/luci/luci-go/common/api/logdog_coordinator/admin/v1"
|
| logsPb "github.com/luci/luci-go/common/api/logdog_coordinator/logs/v1"
|
| registrationPb "github.com/luci/luci-go/common/api/logdog_coordinator/registration/v1"
|
| servicesPb "github.com/luci/luci-go/common/api/logdog_coordinator/services/v1"
|
| log "github.com/luci/luci-go/common/logging"
|
| "github.com/luci/luci-go/server/discovery"
|
| - "github.com/luci/luci-go/server/middleware"
|
| "github.com/luci/luci-go/server/prpc"
|
| + "github.com/luci/luci-go/server/router"
|
| "golang.org/x/net/context"
|
| "google.golang.org/appengine"
|
|
|
| // Include mutations package so its Mutations will register with tumble via
|
| // init().
|
| _ "github.com/luci/luci-go/appengine/logdog/coordinator/mutations"
|
| )
|
|
|
| -// base is the root of the middleware chain.
|
| -func base(installConfig bool) middleware.Base {
|
| - return func(h middleware.Handler) httprouter.Handle {
|
| - if installConfig {
|
| - h = config.WithConfig(h)
|
| - }
|
| - h = coordinator.WithProdServices(h)
|
| - return gaemiddleware.BaseProd(h)
|
| +// base returns the root middleware chain.
|
| +func base(installConfig bool) router.MiddlewareChain {
|
| + m := append(gaemiddleware.BaseProd(), coordinator.WithProdServices)
|
| + if installConfig {
|
| + m = append(m, config.WithConfig)
|
| }
|
| + return m
|
| }
|
|
|
| // Run installs and executes this site.
|
| func main() {
|
| - router := httprouter.New()
|
| + r := router.New()
|
|
|
| // Setup Cloud Endpoints.
|
| svr := prpc.Server{
|
| AccessControl: accessControl,
|
| }
|
| adminPb.RegisterAdminServer(&svr, admin.New())
|
| servicesPb.RegisterServicesServer(&svr, services.New())
|
| registrationPb.RegisterRegistrationServer(&svr, registration.New())
|
| logsPb.RegisterLogsServer(&svr, logs.New())
|
| discovery.Enable(&svr)
|
|
|
| // Standard HTTP endpoints.
|
| - gaemiddleware.InstallHandlers(router, base(false))
|
| - svr.InstallHandlers(router, base(true))
|
| + gaemiddleware.InstallHandlers(r, base(false))
|
| + svr.InstallHandlers(r, base(true))
|
|
|
| // Redirect "/" to "/app/".
|
| - router.GET("/", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
| - http.Redirect(w, r, "/app/", http.StatusFound)
|
| + r.GET("/", nil, func(c *router.Context) {
|
| + http.Redirect(c.Writer, c.Request, "/app/", http.StatusFound)
|
| })
|
|
|
| - http.Handle("/", router)
|
| + http.Handle("/", r)
|
| appengine.Main()
|
| }
|
|
|
| func accessControl(c context.Context, origin string) bool {
|
| cfg, err := config.Load(c)
|
| if err != nil {
|
| log.WithError(err).Errorf(c, "Failed to get config for access control check.")
|
| return false
|
| }
|
|
|
|
|