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

Unified 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: Update tests 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 side-by-side diff with in-line comments
Download patch
Index: appengine/cmd/logdog_coordinator/services/main.go
diff --git a/appengine/cmd/logdog_coordinator/services/main.go b/appengine/cmd/logdog_coordinator/services/main.go
index 1edfb9897549c9694772d928b59bb12cb07f4723..a896b47669606b96daee7e40e02ab95fb038e84c 100644
--- a/appengine/cmd/logdog_coordinator/services/main.go
+++ b/appengine/cmd/logdog_coordinator/services/main.go
@@ -7,7 +7,6 @@ package module
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"
@@ -15,8 +14,8 @@ import (
"github.com/luci/luci-go/appengine/logdog/coordinator/endpoints/services"
registrationPb "github.com/luci/luci-go/common/api/logdog_coordinator/registration/v1"
servicesPb "github.com/luci/luci-go/common/api/logdog_coordinator/services/v1"
- "github.com/luci/luci-go/server/middleware"
"github.com/luci/luci-go/server/prpc"
+ "github.com/luci/luci-go/server/router"
// Include mutations package so its Mutations will register with tumble via
// init().
@@ -24,15 +23,17 @@ import (
)
// base is the root of the middleware chain.
-func base(h middleware.Handler) httprouter.Handle {
- h = config.WithConfig(h)
- h = coordinator.WithProdServices(h)
- return gaemiddleware.BaseProd(h)
+func base() []router.Handler {
+ return append(
+ gaemiddleware.BaseProd(),
+ coordinator.WithProdServices(),
+ config.WithConfig(),
+ )
}
// Run installs and executes this site.
func init() {
- router := httprouter.New()
+ r := router.New()
// Setup Cloud Endpoints.
svr := prpc.Server{}
@@ -40,7 +41,7 @@ func init() {
registrationPb.RegisterRegistrationServer(&svr, registration.New())
// Standard HTTP endpoints.
- svr.InstallHandlers(router, base)
+ svr.InstallHandlers(r, base())
- http.Handle("/", router)
+ http.Handle("/", r)
}

Powered by Google App Engine
This is Rietveld 408576698