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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « appengine/gaetesting/middleware.go ('k') | appengine/logdog/coordinator/service.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package config 5 package config
6 6
7 import ( 7 import (
8 "net/http" 8 "net/http"
9 9
10 "github.com/julienschmidt/httprouter"
11 log "github.com/luci/luci-go/common/logging" 10 log "github.com/luci/luci-go/common/logging"
12 » "github.com/luci/luci-go/server/middleware" 11 » "github.com/luci/luci-go/server/router"
13 » "golang.org/x/net/context"
14 ) 12 )
15 13
16 // WithConfig is a middleware.Handler that installs the LogDog Coordinator 14 // WithConfig is a middleware that installs the LogDog Coordinator
17 // configuration into the Context. 15 // configuration into the Context.
18 func WithConfig(h middleware.Handler) middleware.Handler { 16 func WithConfig(c *router.Context, next router.Handler) {
19 » return func(c context.Context, rw http.ResponseWriter, r *http.Request, params httprouter.Params) { 17 » if err := UseConfig(&c.Context); err != nil {
20 » » if err := UseConfig(&c); err != nil { 18 » » log.WithError(err).Errorf(c.Context, "Failed to install service configuration.")
21 » » » log.WithError(err).Errorf(c, "Failed to install service configuration.") 19 » » c.Writer.WriteHeader(http.StatusInternalServerError)
22 20 » » return
23 » » » rw.WriteHeader(http.StatusInternalServerError)
24 » » » return
25 » » }
26 » » h(c, rw, r, params)
27 } 21 }
22 next(c)
28 } 23 }
OLDNEW
« 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