Skip to content

Commit

Permalink
refactor(middlewares): rename duration middleware to stats middleware…
Browse files Browse the repository at this point in the history
… because it records more than duration
  • Loading branch information
jeamon committed Nov 12, 2023
1 parent f40fe78 commit b7a2265
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api.middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ type MiddlewareMap struct {
ops MiddlewareFunc
}

// DurationMiddleware is a middleware that logs the duration it takes to handle each request,
// StatsMiddleware is a middleware that logs the duration it takes to handle each request,
// then update the number of http status codes returned for internal ops statistics purposes.
func (api *APIHandler) DurationMiddleware(next httprouter.Handle) httprouter.Handle {
func (api *APIHandler) StatsMiddleware(next httprouter.Handle) httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
logger := api.GetLoggerFromContext(r.Context())
start := api.clock.Now()
Expand Down Expand Up @@ -202,7 +202,7 @@ func (api *APIHandler) MiddlewaresStacks() (*Middlewares, *Middlewares) {
api.AddLoggerMiddleware,
CORSMiddleware,
api.TimeoutMiddleware,
api.DurationMiddleware,
api.StatsMiddleware,
}

middlewaresOps := Middlewares{
Expand All @@ -212,7 +212,7 @@ func (api *APIHandler) MiddlewaresStacks() (*Middlewares, *Middlewares) {
api.AddLoggerMiddleware,
CORSMiddleware,
api.TimeoutMiddleware,
api.DurationMiddleware,
api.StatsMiddleware,
}
return &middlewaresPublic, &middlewaresOps
}

0 comments on commit b7a2265

Please sign in to comment.