| OLD | NEW |
| 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 } |
| OLD | NEW |