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

Unified Diff: appengine/tsmon/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/tsmon/middleware.go
diff --git a/appengine/tsmon/middleware.go b/appengine/tsmon/middleware.go
index 5014b81405ede68ee3d3871daf5ac36050a29b28..5957d6ba1fea77557d7c87303eb2aee53d1b4ec3 100644
--- a/appengine/tsmon/middleware.go
+++ b/appengine/tsmon/middleware.go
@@ -10,13 +10,11 @@ package tsmon
import (
"fmt"
- "net/http"
"strings"
"sync"
"time"
"github.com/golang/protobuf/proto"
- "github.com/julienschmidt/httprouter"
"golang.org/x/net/context"
"github.com/luci/gae/service/info"
@@ -28,7 +26,7 @@ import (
"github.com/luci/luci-go/common/tsmon/monitor"
"github.com/luci/luci-go/common/tsmon/store"
"github.com/luci/luci-go/common/tsmon/target"
- "github.com/luci/luci-go/server/middleware"
+ "github.com/luci/luci-go/server/router"
)
// State holds the configuration of the tsmon library for GAE.
@@ -61,12 +59,12 @@ type State struct {
// Middleware returns a middleware that must be inserted into the chain to
// enable tsmon metrics to be sent on App Engine.
-func (s *State) Middleware(h middleware.Handler) middleware.Handler {
- return func(c context.Context, rw http.ResponseWriter, r *http.Request, p httprouter.Params) {
- state, settings := s.checkSettings(c)
- h(c, rw, r, p)
+func (s *State) Middleware() router.Handler {
+ return func(c *router.Context) {
+ state, settings := s.checkSettings(c.Context)
+ c.Next()
if settings.Enabled {
- s.flushIfNeeded(c, state, settings)
+ s.flushIfNeeded(c.Context, state, settings)
}
}
}

Powered by Google App Engine
This is Rietveld 408576698