mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-29 14:39:40 +02:00
Merge pull request #180 from travisgroth/response_writer_middleware
Relocate wrapped ResponseWriter to middleware
This commit is contained in:
commit
fb92466f45
3 changed files with 4 additions and 3 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/middleware/responsewriter"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
|
@ -164,7 +165,7 @@ func AccessHandler(f func(r *http.Request, status, size int, duration time.Durat
|
|||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
start := time.Now()
|
||||
lw := NewWrapResponseWriter(w, r.ProtoMajor)
|
||||
lw := responsewriter.NewWrapResponseWriter(w, r.ProtoMajor)
|
||||
next.ServeHTTP(lw, r)
|
||||
f(r, lw.Status(), lw.BytesWritten(), time.Since(start))
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package log // import "github.com/pomerium/pomerium/internal/log"
|
||||
package responsewriter
|
||||
|
||||
// The original work was derived from Goji's middleware, source:
|
||||
// https://github.com/zenazn/goji/tree/master/web/middleware
|
|
@ -1,4 +1,4 @@
|
|||
package log // import "github.com/pomerium/pomerium/internal/log"
|
||||
package responsewriter
|
||||
|
||||
import (
|
||||
"net/http/httptest"
|
Loading…
Add table
Add a link
Reference in a new issue