diff options
Diffstat (limited to 'vendor/github.com/go-chi/chi/middleware')
6 files changed, 14 insertions, 29 deletions
diff --git a/vendor/github.com/go-chi/chi/middleware/profiler.go b/vendor/github.com/go-chi/chi/middleware/profiler.go index 1d44b8259a..f5b62f7c32 100644 --- a/vendor/github.com/go-chi/chi/middleware/profiler.go +++ b/vendor/github.com/go-chi/chi/middleware/profiler.go @@ -23,10 +23,10 @@ func Profiler() http.Handler { r.Use(NoCache) r.Get("/", func(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, r.RequestURI+"/pprof/", 301) + http.Redirect(w, r, r.RequestURI+"/pprof/", http.StatusMovedPermanently) }) r.HandleFunc("/pprof", func(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, r.RequestURI+"/", 301) + http.Redirect(w, r, r.RequestURI+"/", http.StatusMovedPermanently) }) r.HandleFunc("/pprof/*", pprof.Index) diff --git a/vendor/github.com/go-chi/chi/middleware/route_headers.go b/vendor/github.com/go-chi/chi/middleware/route_headers.go index 7ee30c8773..0e67b5f768 100644 --- a/vendor/github.com/go-chi/chi/middleware/route_headers.go +++ b/vendor/github.com/go-chi/chi/middleware/route_headers.go @@ -50,7 +50,7 @@ func RouteHeaders() HeaderRouter { type HeaderRouter map[string][]HeaderRoute -func (hr HeaderRouter) Route(header string, match string, middlewareHandler func(next http.Handler) http.Handler) HeaderRouter { +func (hr HeaderRouter) Route(header, match string, middlewareHandler func(next http.Handler) http.Handler) HeaderRouter { header = strings.ToLower(header) k := hr[header] if k == nil { diff --git a/vendor/github.com/go-chi/chi/middleware/strip.go b/vendor/github.com/go-chi/chi/middleware/strip.go index 1082d713ef..992184dbf6 100644 --- a/vendor/github.com/go-chi/chi/middleware/strip.go +++ b/vendor/github.com/go-chi/chi/middleware/strip.go @@ -52,8 +52,8 @@ func RedirectSlashes(next http.Handler) http.Handler { } else { path = path[:len(path)-1] } - redirectUrl := fmt.Sprintf("//%s%s", r.Host, path) - http.Redirect(w, r, redirectUrl, 301) + redirectURL := fmt.Sprintf("//%s%s", r.Host, path) + http.Redirect(w, r, redirectURL, 301) return } next.ServeHTTP(w, r) diff --git a/vendor/github.com/go-chi/chi/middleware/throttle.go b/vendor/github.com/go-chi/chi/middleware/throttle.go index 01100b7ada..7bb2e804f2 100644 --- a/vendor/github.com/go-chi/chi/middleware/throttle.go +++ b/vendor/github.com/go-chi/chi/middleware/throttle.go @@ -35,7 +35,7 @@ func Throttle(limit int) func(http.Handler) http.Handler { // ThrottleBacklog is a middleware that limits number of currently processed // requests at a time and provides a backlog for holding a finite number of // pending requests. -func ThrottleBacklog(limit int, backlogLimit int, backlogTimeout time.Duration) func(http.Handler) http.Handler { +func ThrottleBacklog(limit, backlogLimit int, backlogTimeout time.Duration) func(http.Handler) http.Handler { return ThrottleWithOpts(ThrottleOpts{Limit: limit, BacklogLimit: backlogLimit, BacklogTimeout: backlogTimeout}) } diff --git a/vendor/github.com/go-chi/chi/middleware/value.go b/vendor/github.com/go-chi/chi/middleware/value.go index fbbd0393fb..a9dfd4345d 100644 --- a/vendor/github.com/go-chi/chi/middleware/value.go +++ b/vendor/github.com/go-chi/chi/middleware/value.go @@ -6,7 +6,7 @@ import ( ) // WithValue is a middleware that sets a given key/value in a context chain. -func WithValue(key interface{}, val interface{}) func(next http.Handler) http.Handler { +func WithValue(key, val interface{}) func(next http.Handler) http.Handler { return func(next http.Handler) http.Handler { fn := func(w http.ResponseWriter, r *http.Request) { r = r.WithContext(context.WithValue(r.Context(), key, val)) diff --git a/vendor/github.com/go-chi/chi/middleware/wrap_writer.go b/vendor/github.com/go-chi/chi/middleware/wrap_writer.go index 382a523e48..6438c7a653 100644 --- a/vendor/github.com/go-chi/chi/middleware/wrap_writer.go +++ b/vendor/github.com/go-chi/chi/middleware/wrap_writer.go @@ -19,19 +19,16 @@ func NewWrapResponseWriter(w http.ResponseWriter, protoMajor int) WrapResponseWr if protoMajor == 2 { _, ps := w.(http.Pusher) - if fl && ps { + if fl || ps { return &http2FancyWriter{bw} } } else { _, hj := w.(http.Hijacker) _, rf := w.(io.ReaderFrom) - if fl && hj && rf { + if fl || hj || rf { return &httpFancyWriter{bw} } } - if fl { - return &flushWriter{bw} - } return &bw } @@ -110,18 +107,6 @@ func (b *basicWriter) Unwrap() http.ResponseWriter { return b.ResponseWriter } -type flushWriter struct { - basicWriter -} - -func (f *flushWriter) Flush() { - f.wroteHeader = true - fl := f.basicWriter.ResponseWriter.(http.Flusher) - fl.Flush() -} - -var _ http.Flusher = &flushWriter{} - // httpFancyWriter is a HTTP writer that additionally satisfies // http.Flusher, http.Hijacker, and io.ReaderFrom. It exists for the common case // of wrapping the http.ResponseWriter that package http gives you, in order to @@ -141,10 +126,6 @@ func (f *httpFancyWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { return hj.Hijack() } -func (f *http2FancyWriter) Push(target string, opts *http.PushOptions) error { - return f.basicWriter.ResponseWriter.(http.Pusher).Push(target, opts) -} - func (f *httpFancyWriter) ReadFrom(r io.Reader) (int64, error) { if f.basicWriter.tee != nil { n, err := io.Copy(&f.basicWriter, r) @@ -160,7 +141,6 @@ func (f *httpFancyWriter) ReadFrom(r io.Reader) (int64, error) { var _ http.Flusher = &httpFancyWriter{} var _ http.Hijacker = &httpFancyWriter{} -var _ http.Pusher = &http2FancyWriter{} var _ io.ReaderFrom = &httpFancyWriter{} // http2FancyWriter is a HTTP2 writer that additionally satisfies @@ -177,4 +157,9 @@ func (f *http2FancyWriter) Flush() { fl.Flush() } +func (f *http2FancyWriter) Push(target string, opts *http.PushOptions) error { + return f.basicWriter.ResponseWriter.(http.Pusher).Push(target, opts) +} + var _ http.Flusher = &http2FancyWriter{} +var _ http.Pusher = &http2FancyWriter{} |