aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-chi
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/go-chi')
-rw-r--r--vendor/github.com/go-chi/chi/CHANGELOG.md19
-rw-r--r--vendor/github.com/go-chi/chi/Makefile14
-rw-r--r--vendor/github.com/go-chi/chi/context.go27
-rw-r--r--vendor/github.com/go-chi/chi/go.mod2
-rw-r--r--vendor/github.com/go-chi/chi/middleware/profiler.go4
-rw-r--r--vendor/github.com/go-chi/chi/middleware/route_headers.go2
-rw-r--r--vendor/github.com/go-chi/chi/middleware/strip.go4
-rw-r--r--vendor/github.com/go-chi/chi/middleware/throttle.go2
-rw-r--r--vendor/github.com/go-chi/chi/middleware/value.go2
-rw-r--r--vendor/github.com/go-chi/chi/middleware/wrap_writer.go29
-rw-r--r--vendor/github.com/go-chi/chi/mux.go19
-rw-r--r--vendor/github.com/go-chi/chi/tree.go7
12 files changed, 61 insertions, 70 deletions
diff --git a/vendor/github.com/go-chi/chi/CHANGELOG.md b/vendor/github.com/go-chi/chi/CHANGELOG.md
index 2e337506a4..7dd079157f 100644
--- a/vendor/github.com/go-chi/chi/CHANGELOG.md
+++ b/vendor/github.com/go-chi/chi/CHANGELOG.md
@@ -1,5 +1,24 @@
# Changelog
+## v1.5.4 (2021-02-27)
+
+- Undo prior retraction in v1.5.3 as we prepare for v5.0.0 release
+- History of changes: see https://github.com/go-chi/chi/compare/v1.5.3...v1.5.4
+
+
+## v1.5.3 (2021-02-21)
+
+- Update go.mod to go 1.16 with new retract directive marking all versions without prior go.mod support
+- History of changes: see https://github.com/go-chi/chi/compare/v1.5.2...v1.5.3
+
+
+## v1.5.2 (2021-02-10)
+
+- Reverting allocation optimization as a precaution as go test -race fails.
+- Minor improvements, see history below
+- History of changes: see https://github.com/go-chi/chi/compare/v1.5.1...v1.5.2
+
+
## v1.5.1 (2020-12-06)
- Performance improvement: removing 1 allocation by foregoing context.WithValue, thank you @bouk for
diff --git a/vendor/github.com/go-chi/chi/Makefile b/vendor/github.com/go-chi/chi/Makefile
new file mode 100644
index 0000000000..b96c92dd21
--- /dev/null
+++ b/vendor/github.com/go-chi/chi/Makefile
@@ -0,0 +1,14 @@
+all:
+ @echo "**********************************************************"
+ @echo "** chi build tool **"
+ @echo "**********************************************************"
+
+
+test:
+ go clean -testcache && $(MAKE) test-router && $(MAKE) test-middleware
+
+test-router:
+ go test -race -v .
+
+test-middleware:
+ go test -race -v ./middleware
diff --git a/vendor/github.com/go-chi/chi/context.go b/vendor/github.com/go-chi/chi/context.go
index 7dec3f0c01..8c97f214a9 100644
--- a/vendor/github.com/go-chi/chi/context.go
+++ b/vendor/github.com/go-chi/chi/context.go
@@ -4,7 +4,6 @@ import (
"context"
"net/http"
"strings"
- "time"
)
// URLParam returns the url parameter from a http.Request object.
@@ -146,32 +145,6 @@ func (s *RouteParams) Add(key, value string) {
s.Values = append(s.Values, value)
}
-// directContext provides direct access to the routing *Context object,
-// while implementing the context.Context interface, thereby allowing
-// us to saving 1 allocation during routing.
-type directContext Context
-
-var _ context.Context = (*directContext)(nil)
-
-func (d *directContext) Deadline() (deadline time.Time, ok bool) {
- return d.parentCtx.Deadline()
-}
-
-func (d *directContext) Done() <-chan struct{} {
- return d.parentCtx.Done()
-}
-
-func (d *directContext) Err() error {
- return d.parentCtx.Err()
-}
-
-func (d *directContext) Value(key interface{}) interface{} {
- if key == RouteCtxKey {
- return (*Context)(d)
- }
- return d.parentCtx.Value(key)
-}
-
// contextKey is a value for use with context.WithValue. It's used as
// a pointer so it fits in an interface{} without allocation. This technique
// for defining context keys was copied from Go 1.7's new use of context in net/http.
diff --git a/vendor/github.com/go-chi/chi/go.mod b/vendor/github.com/go-chi/chi/go.mod
index cffc732e6d..769b90190a 100644
--- a/vendor/github.com/go-chi/chi/go.mod
+++ b/vendor/github.com/go-chi/chi/go.mod
@@ -1,3 +1,3 @@
module github.com/go-chi/chi
-go 1.15
+go 1.16
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{}
diff --git a/vendor/github.com/go-chi/chi/mux.go b/vendor/github.com/go-chi/chi/mux.go
index c6fdb8a0f3..146643b04c 100644
--- a/vendor/github.com/go-chi/chi/mux.go
+++ b/vendor/github.com/go-chi/chi/mux.go
@@ -1,6 +1,7 @@
package chi
import (
+ "context"
"fmt"
"net/http"
"strings"
@@ -79,8 +80,8 @@ func (mx *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
rctx.Routes = mx
rctx.parentCtx = r.Context()
- // NOTE: r.WithContext() causes 2 allocations
- r = r.WithContext((*directContext)(rctx))
+ // NOTE: r.WithContext() causes 2 allocations and context.WithValue() causes 1 allocation
+ r = r.WithContext(context.WithValue(r.Context(), RouteCtxKey, rctx))
// Serve the request and once its done, put the request context back in the sync pool
mx.handler.ServeHTTP(w, r)
@@ -187,17 +188,16 @@ func (mx *Mux) Trace(pattern string, handlerFn http.HandlerFunc) {
func (mx *Mux) NotFound(handlerFn http.HandlerFunc) {
// Build NotFound handler chain
m := mx
- hFn := handlerFn
+ h := Chain(mx.middlewares...).HandlerFunc(handlerFn).ServeHTTP
if mx.inline && mx.parent != nil {
m = mx.parent
- hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP
}
// Update the notFoundHandler from this point forward
- m.notFoundHandler = hFn
+ m.notFoundHandler = h
m.updateSubRoutes(func(subMux *Mux) {
if subMux.notFoundHandler == nil {
- subMux.NotFound(hFn)
+ subMux.NotFound(h)
}
})
}
@@ -207,17 +207,16 @@ func (mx *Mux) NotFound(handlerFn http.HandlerFunc) {
func (mx *Mux) MethodNotAllowed(handlerFn http.HandlerFunc) {
// Build MethodNotAllowed handler chain
m := mx
- hFn := handlerFn
+ h := Chain(mx.middlewares...).HandlerFunc(handlerFn).ServeHTTP
if mx.inline && mx.parent != nil {
m = mx.parent
- hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP
}
// Update the methodNotAllowedHandler from this point forward
- m.methodNotAllowedHandler = hFn
+ m.methodNotAllowedHandler = h
m.updateSubRoutes(func(subMux *Mux) {
if subMux.methodNotAllowedHandler == nil {
- subMux.MethodNotAllowed(hFn)
+ subMux.MethodNotAllowed(h)
}
})
}
diff --git a/vendor/github.com/go-chi/chi/tree.go b/vendor/github.com/go-chi/chi/tree.go
index fbea31ab9a..8057c52813 100644
--- a/vendor/github.com/go-chi/chi/tree.go
+++ b/vendor/github.com/go-chi/chi/tree.go
@@ -6,7 +6,6 @@ package chi
import (
"fmt"
- "math"
"net/http"
"regexp"
"sort"
@@ -55,10 +54,10 @@ func RegisterMethod(method string) {
return
}
n := len(methodMap)
- if n > strconv.IntSize {
+ if n > strconv.IntSize-2 {
panic(fmt.Sprintf("chi: max number of methods reached (%d)", strconv.IntSize))
}
- mt := methodTyp(math.Exp2(float64(n)))
+ mt := methodTyp(2 << n)
methodMap[method] = mt
mALL |= mt
}
@@ -430,6 +429,8 @@ func (n *node) findRoute(rctx *Context, method methodTyp, path string) *node {
} else {
continue
}
+ } else if ntyp == ntRegexp && p == 0 {
+ continue
}
if ntyp == ntRegexp && xn.rex != nil {