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

Unified Diff: appengine/gaetesting/middleware.go

Issue 2043423004: Make HTTP middleware easier to use (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Convert remaining source files 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/gaetesting/middleware.go
diff --git a/appengine/gaetesting/middleware.go b/appengine/gaetesting/middleware.go
index 2cedb18cdf4041cde0331af3ca04bf58d6c9c151..ccd8dead3b3a78cfc8cc3d7864cda4b4d408b57e 100644
--- a/appengine/gaetesting/middleware.go
+++ b/appengine/gaetesting/middleware.go
@@ -5,25 +5,21 @@
package gaetesting
import (
- "net/http"
-
- "github.com/julienschmidt/httprouter"
"golang.org/x/net/context"
"github.com/luci/gae/impl/memory"
- "github.com/luci/luci-go/server/middleware"
"github.com/luci/luci-go/server/proccache"
+ "github.com/luci/luci-go/server/router"
"github.com/luci/luci-go/server/secrets/testsecrets"
)
-// BaseTest adapts a middleware-style handler to a httprouter.Handle. It passes
-// a new context to `h` with the following services installed:
+// BaseTest is a middleware that passes a new context to the next handler
+// with the following services installed:
// * github.com/luci/gae/impl/memory (in-memory appengine services)
// * github.com/luci/luci-go/server/secrets/testsecrets (access to fake secret keys)
-func BaseTest(h middleware.Handler) httprouter.Handle {
- return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
- h(TestingContext(), rw, r, p)
- }
+func BaseTest(c *router.Context, next router.Handler) {
+ c.Context = TestingContext()
+ next(c)
}
// TestingContext returns context with base services installed.

Powered by Google App Engine
This is Rietveld 408576698