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

Unified Diff: common/testing/prpctest/server.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: common/testing/prpctest/server.go
diff --git a/common/testing/prpctest/server.go b/common/testing/prpctest/server.go
index 670482440596f82ba99e157f6af35790aee079a5..63cc4358505c6d251b47d630fec0e281f98a219d 100644
--- a/common/testing/prpctest/server.go
+++ b/common/testing/prpctest/server.go
@@ -12,11 +12,10 @@ import (
"net/http/httptest"
"net/url"
- "github.com/julienschmidt/httprouter"
prpcCommon "github.com/luci/luci-go/common/prpc"
"github.com/luci/luci-go/server/auth"
- "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"
)
@@ -25,8 +24,8 @@ type Server struct {
prpc.Server
// Base is the base middleware generator factory. It is handed the Context
- // passed to Start. If nil, middleware.TestingBase will be used.
- Base func(context.Context) middleware.Base
+ // passed to Start. If Base is nil, middleware.TestingBase will be used.
+ Base func(c context.Context) router.Base
// HTTP is the active HTTP test server. It will be valid when the Server is
// running.
@@ -42,11 +41,11 @@ func (s *Server) Start(c context.Context) {
s.Authenticator = auth.Authenticator{}
mwb := s.Base
if mwb == nil {
- mwb = middleware.TestingBase
+ mwb = router.TestingBase
}
- r := httprouter.New()
- s.InstallHandlers(r, mwb(c))
+ r := router.New()
+ s.InstallHandlers(r, mwb(c)())
s.HTTP = httptest.NewServer(r)
}

Powered by Google App Engine
This is Rietveld 408576698