diff --git a/assets/catnip/go.mod b/assets/catnip/go.mod index 4326ee382..878fb9ac6 100644 --- a/assets/catnip/go.mod +++ b/assets/catnip/go.mod @@ -4,7 +4,7 @@ go 1.21 require ( code.cloudfoundry.org/clock v1.1.0 - github.com/go-chi/chi/v5 v5.0.11 + github.com/go-chi/chi/v5 v5.0.12 github.com/onsi/ginkgo/v2 v2.15.0 github.com/onsi/gomega v1.31.1 ) diff --git a/assets/catnip/go.sum b/assets/catnip/go.sum index 8c6f1bafb..b9eafec00 100644 --- a/assets/catnip/go.sum +++ b/assets/catnip/go.sum @@ -6,8 +6,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA= -github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s= +github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= diff --git a/assets/catnip/vendor/github.com/go-chi/chi/v5/CHANGELOG.md b/assets/catnip/vendor/github.com/go-chi/chi/v5/CHANGELOG.md index 83d5aa28f..25b45b974 100644 --- a/assets/catnip/vendor/github.com/go-chi/chi/v5/CHANGELOG.md +++ b/assets/catnip/vendor/github.com/go-chi/chi/v5/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v5.0.12 (2024-02-16) + +- History of changes: see https://github.com/go-chi/chi/compare/v5.0.11...v5.0.12 + + ## v5.0.11 (2023-12-19) - History of changes: see https://github.com/go-chi/chi/compare/v5.0.10...v5.0.11 diff --git a/assets/catnip/vendor/github.com/go-chi/chi/v5/README.md b/assets/catnip/vendor/github.com/go-chi/chi/v5/README.md index 4b1c99d12..21cbb0fc0 100644 --- a/assets/catnip/vendor/github.com/go-chi/chi/v5/README.md +++ b/assets/catnip/vendor/github.com/go-chi/chi/v5/README.md @@ -354,6 +354,7 @@ with `net/http` can be used with chi's mux. | [RouteHeaders] | Route handling for request headers | | [SetHeader] | Short-hand middleware to set a response header key/value | | [StripSlashes] | Strip slashes on routing paths | +| [Sunset] | Sunset set Deprecation/Sunset header to response | | [Throttle] | Puts a ceiling on the number of concurrent requests | | [Timeout] | Signals to the request context when the timeout deadline is reached | | [URLFormat] | Parse extension from url and put it on request context | @@ -380,6 +381,7 @@ with `net/http` can be used with chi's mux. [RouteHeaders]: https://pkg.go.dev/github.com/go-chi/chi/middleware#RouteHeaders [SetHeader]: https://pkg.go.dev/github.com/go-chi/chi/middleware#SetHeader [StripSlashes]: https://pkg.go.dev/github.com/go-chi/chi/middleware#StripSlashes +[Sunset]: https://pkg.go.dev/github.com/go-chi/chi/v5/middleware#Sunset [Throttle]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Throttle [ThrottleBacklog]: https://pkg.go.dev/github.com/go-chi/chi/middleware#ThrottleBacklog [ThrottleWithOpts]: https://pkg.go.dev/github.com/go-chi/chi/middleware#ThrottleWithOpts diff --git a/assets/catnip/vendor/github.com/go-chi/chi/v5/middleware/maybe.go b/assets/catnip/vendor/github.com/go-chi/chi/v5/middleware/maybe.go index d8ca63b91..eabca005a 100644 --- a/assets/catnip/vendor/github.com/go-chi/chi/v5/middleware/maybe.go +++ b/assets/catnip/vendor/github.com/go-chi/chi/v5/middleware/maybe.go @@ -4,7 +4,7 @@ import "net/http" // Maybe middleware will allow you to change the flow of the middleware stack execution depending on return // value of maybeFn(request). This is useful for example if you'd like to skip a middleware handler if -// a request does not satisfied the maybeFn logic. +// a request does not satisfy the maybeFn logic. func Maybe(mw func(http.Handler) http.Handler, maybeFn func(r *http.Request) bool) func(http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/assets/catnip/vendor/github.com/go-chi/chi/v5/mux.go b/assets/catnip/vendor/github.com/go-chi/chi/v5/mux.go index 735ab2323..6dc1904d9 100644 --- a/assets/catnip/vendor/github.com/go-chi/chi/v5/mux.go +++ b/assets/catnip/vendor/github.com/go-chi/chi/v5/mux.go @@ -107,12 +107,24 @@ func (mx *Mux) Use(middlewares ...func(http.Handler) http.Handler) { // Handle adds the route `pattern` that matches any http method to // execute the `handler` http.Handler. func (mx *Mux) Handle(pattern string, handler http.Handler) { + parts := strings.SplitN(pattern, " ", 2) + if len(parts) == 2 { + mx.Method(parts[0], parts[1], handler) + return + } + mx.handle(mALL, pattern, handler) } // HandleFunc adds the route `pattern` that matches any http method to // execute the `handlerFn` http.HandlerFunc. func (mx *Mux) HandleFunc(pattern string, handlerFn http.HandlerFunc) { + parts := strings.SplitN(pattern, " ", 2) + if len(parts) == 2 { + mx.Method(parts[0], parts[1], handlerFn) + return + } + mx.handle(mALL, pattern, handlerFn) } @@ -440,6 +452,10 @@ func (mx *Mux) routeHTTP(w http.ResponseWriter, r *http.Request) { // Find the route if _, _, h := mx.tree.FindRoute(rctx, method, routePath); h != nil { + if supportsPathValue { + setPathValue(rctx, r) + } + h.ServeHTTP(w, r) return } diff --git a/assets/catnip/vendor/github.com/go-chi/chi/v5/path_value.go b/assets/catnip/vendor/github.com/go-chi/chi/v5/path_value.go new file mode 100644 index 000000000..7e78171e5 --- /dev/null +++ b/assets/catnip/vendor/github.com/go-chi/chi/v5/path_value.go @@ -0,0 +1,20 @@ +//go:build go1.22 +// +build go1.22 + +package chi + +import "net/http" + +// supportsPathValue is true if the Go version is 1.22 and above. +// +// If this is true, `net/http.Request` has methods `SetPathValue` and `PathValue`. +const supportsPathValue = true + +// setPathValue sets the path values in the Request value +// based on the provided request context. +func setPathValue(rctx *Context, r *http.Request) { + for i, key := range rctx.URLParams.Keys { + value := rctx.URLParams.Values[i] + r.SetPathValue(key, value) + } +} diff --git a/assets/catnip/vendor/github.com/go-chi/chi/v5/path_value_fallback.go b/assets/catnip/vendor/github.com/go-chi/chi/v5/path_value_fallback.go new file mode 100644 index 000000000..f551781a4 --- /dev/null +++ b/assets/catnip/vendor/github.com/go-chi/chi/v5/path_value_fallback.go @@ -0,0 +1,19 @@ +//go:build !go1.22 +// +build !go1.22 + +package chi + +import "net/http" + +// supportsPathValue is true if the Go version is 1.22 and above. +// +// If this is true, `net/http.Request` has methods `SetPathValue` and `PathValue`. +const supportsPathValue = false + +// setPathValue sets the path values in the Request value +// based on the provided request context. +// +// setPathValue is only supported in Go 1.22 and above so +// this is just a blank function so that it compiles. +func setPathValue(rctx *Context, r *http.Request) { +} diff --git a/assets/catnip/vendor/modules.txt b/assets/catnip/vendor/modules.txt index 98db44c0d..33940961b 100644 --- a/assets/catnip/vendor/modules.txt +++ b/assets/catnip/vendor/modules.txt @@ -2,7 +2,7 @@ ## explicit; go 1.20 code.cloudfoundry.org/clock code.cloudfoundry.org/clock/fakeclock -# github.com/go-chi/chi/v5 v5.0.11 +# github.com/go-chi/chi/v5 v5.0.12 ## explicit; go 1.14 github.com/go-chi/chi/v5 github.com/go-chi/chi/v5/middleware