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

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: gaemiddleware: add middleware func for WithProd 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
« no previous file with comments | « appengine/gaetesting/middleware.go ('k') | appengine/logdog/coordinator/service.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..de73495a95c4f700a70dfb9d6a1440ad95e1443b 100644
--- a/appengine/logdog/coordinator/config/middleware.go
+++ b/appengine/logdog/coordinator/config/middleware.go
@@ -1,28 +1,23 @@
// Copyright 2015 The LUCI Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
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
+// WithConfig is a middleware 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
- }
- h(c, rw, r, params)
+func WithConfig(c *router.Context, next router.Handler) {
+ if err := UseConfig(&c.Context); err != nil {
+ log.WithError(err).Errorf(c.Context, "Failed to install service configuration.")
+ c.Writer.WriteHeader(http.StatusInternalServerError)
+ return
}
+ next(c)
}
« no previous file with comments | « appengine/gaetesting/middleware.go ('k') | appengine/logdog/coordinator/service.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698