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

Unified Diff: server/auth/db.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: server/auth/db.go
diff --git a/server/auth/db.go b/server/auth/db.go
index 61ca54c985f49dedcc81ae1554443c862807a67e..2d01ff8a70691ba6516f578f56337f4ed6ed4e78 100644
--- a/server/auth/db.go
+++ b/server/auth/db.go
@@ -8,11 +8,9 @@ import (
"errors"
"fmt"
"net"
- "net/http"
"strings"
"time"
- "github.com/julienschmidt/httprouter"
"golang.org/x/net/context"
"github.com/luci/luci-go/common/clock"
@@ -22,7 +20,7 @@ import (
"github.com/luci/luci-go/server/auth/identity"
"github.com/luci/luci-go/server/auth/service/protocol"
- "github.com/luci/luci-go/server/middleware"
+ "github.com/luci/luci-go/server/router"
"github.com/luci/luci-go/server/secrets"
)
@@ -87,9 +85,9 @@ func UseDB(c context.Context, f DBFactory) context.Context {
// WithDB is middleware that sets given DBFactory in the context before calling
// a handler.
-func WithDB(h middleware.Handler, f DBFactory) middleware.Handler {
- return func(c context.Context, rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
- h(UseDB(c, f), rw, r, p)
+func WithDB(f DBFactory) router.Handler {
+ return func(c *router.Context) {
+ c.Context = UseDB(c.Context, f)
}
}

Powered by Google App Engine
This is Rietveld 408576698