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

Unified Diff: appengine/logdog/coordinator/config/middleware.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/logdog/coordinator/config/middleware.go
diff --git a/appengine/logdog/coordinator/config/middleware.go b/appengine/logdog/coordinator/config/middleware.go
index bef79ceb81eb25e0a01bd82e23f4f04587b2c900..fd4114db09c2835568765e6c67ec72e6b20b89d7 100644
--- a/appengine/logdog/coordinator/config/middleware.go
+++ b/appengine/logdog/coordinator/config/middleware.go
@@ -7,22 +7,18 @@ package config
import (
"net/http"
- "github.com/julienschmidt/httprouter"
log "github.com/luci/luci-go/common/logging"
- "github.com/luci/luci-go/server/middleware"
- "golang.org/x/net/context"
+ "github.com/luci/luci-go/server/router"
)
// WithConfig is a middleware.Handler that installs the LogDog Coordinator
// configuration into the Context.
-func WithConfig(h middleware.Handler) middleware.Handler {
- return func(c context.Context, rw http.ResponseWriter, r *http.Request, params httprouter.Params) {
- if err := UseConfig(&c); err != nil {
- log.WithError(err).Errorf(c, "Failed to install service configuration.")
-
- rw.WriteHeader(http.StatusInternalServerError)
- return
+func WithConfig() router.Handler {
+ return func(c *router.Context) {
+ if err := UseConfig(&c.Context); err != nil {
+ log.WithError(err).Errorf(c.Context, "Failed to install service configuration.")
+ c.Writer.WriteHeader(http.StatusInternalServerError)
+ c.Abort()
}
- h(c, rw, r, params)
}
}

Powered by Google App Engine
This is Rietveld 408576698