Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: appengine/cmd/logdog_coordinator/services/main.go

Issue 2043423004: Make HTTP middleware easier to use (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: gaemiddleware: add middleware func for WithProd Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package module 5 package module
6 6
7 import ( 7 import (
8 "net/http" 8 "net/http"
9 9
10 "github.com/julienschmidt/httprouter"
11 "github.com/luci/luci-go/appengine/gaemiddleware" 10 "github.com/luci/luci-go/appengine/gaemiddleware"
12 "github.com/luci/luci-go/appengine/logdog/coordinator" 11 "github.com/luci/luci-go/appengine/logdog/coordinator"
13 "github.com/luci/luci-go/appengine/logdog/coordinator/config" 12 "github.com/luci/luci-go/appengine/logdog/coordinator/config"
14 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/registra tion" 13 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/registra tion"
15 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/services " 14 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/services "
16 registrationPb "github.com/luci/luci-go/common/api/logdog_coordinator/re gistration/v1" 15 registrationPb "github.com/luci/luci-go/common/api/logdog_coordinator/re gistration/v1"
17 servicesPb "github.com/luci/luci-go/common/api/logdog_coordinator/servic es/v1" 16 servicesPb "github.com/luci/luci-go/common/api/logdog_coordinator/servic es/v1"
18 "github.com/luci/luci-go/server/middleware"
19 "github.com/luci/luci-go/server/prpc" 17 "github.com/luci/luci-go/server/prpc"
18 "github.com/luci/luci-go/server/router"
20 19
21 // Include mutations package so its Mutations will register with tumble via 20 // Include mutations package so its Mutations will register with tumble via
22 // init(). 21 // init().
23 _ "github.com/luci/luci-go/appengine/logdog/coordinator/mutations" 22 _ "github.com/luci/luci-go/appengine/logdog/coordinator/mutations"
24 ) 23 )
25 24
26 // base is the root of the middleware chain. 25 // base returns the root middleware chain.
27 func base(h middleware.Handler) httprouter.Handle { 26 func base() router.MiddlewareChain {
28 » h = config.WithConfig(h) 27 » return append(
29 » h = coordinator.WithProdServices(h) 28 » » gaemiddleware.BaseProd(),
30 » return gaemiddleware.BaseProd(h) 29 » » coordinator.WithProdServices,
30 » » config.WithConfig,
31 » )
31 } 32 }
32 33
33 // Run installs and executes this site. 34 // Run installs and executes this site.
34 func init() { 35 func init() {
35 » router := httprouter.New() 36 » r := router.New()
36 37
37 // Setup Cloud Endpoints. 38 // Setup Cloud Endpoints.
38 svr := prpc.Server{} 39 svr := prpc.Server{}
39 servicesPb.RegisterServicesServer(&svr, services.New()) 40 servicesPb.RegisterServicesServer(&svr, services.New())
40 registrationPb.RegisterRegistrationServer(&svr, registration.New()) 41 registrationPb.RegisterRegistrationServer(&svr, registration.New())
41 42
42 // Standard HTTP endpoints. 43 // Standard HTTP endpoints.
43 » svr.InstallHandlers(router, base) 44 » svr.InstallHandlers(r, base())
44 45
45 » http.Handle("/", router) 46 » http.Handle("/", r)
46 } 47 }
OLDNEW
« no previous file with comments | « appengine/cmd/logdog_coordinator/backend/main.go ('k') | appengine/cmd/logdog_coordinator/vmuser/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698