build(deps): bump github.com/go-chi/chi/v5 from 5.2.2 to 5.2.3
Bumps [github.com/go-chi/chi/v5](https://github.com/go-chi/chi) from 5.2.2 to 5.2.3. - [Release notes](https://github.com/go-chi/chi/releases) - [Changelog](https://github.com/go-chi/chi/blob/master/CHANGELOG.md) - [Commits](https://github.com/go-chi/chi/compare/v5.2.2...v5.2.3) --- updated-dependencies: - dependency-name: github.com/go-chi/chi/v5 dependency-version: 5.2.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
+5
-4
@@ -133,11 +133,12 @@ func (x *Context) RoutePattern() string {
|
||||
return routePattern
|
||||
}
|
||||
|
||||
// replaceWildcards takes a route pattern and recursively replaces all
|
||||
// occurrences of "/*/" to "/".
|
||||
// replaceWildcards takes a route pattern and replaces all occurrences of
|
||||
// "/*/" with "/". It iteratively runs until no wildcards remain to
|
||||
// correctly handle consecutive wildcards.
|
||||
func replaceWildcards(p string) string {
|
||||
if strings.Contains(p, "/*/") {
|
||||
return replaceWildcards(strings.Replace(p, "/*/", "/", -1))
|
||||
for strings.Contains(p, "/*/") {
|
||||
p = strings.ReplaceAll(p, "/*/", "/")
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
+13
-2
@@ -83,12 +83,23 @@ func ThrottleWithOpts(opts ThrottleOpts) func(http.Handler) http.Handler {
|
||||
return
|
||||
|
||||
case btok := <-t.backlogTokens:
|
||||
timer := time.NewTimer(t.backlogTimeout)
|
||||
|
||||
defer func() {
|
||||
t.backlogTokens <- btok
|
||||
}()
|
||||
|
||||
// Try to get a processing token immediately first
|
||||
select {
|
||||
case tok := <-t.tokens:
|
||||
defer func() {
|
||||
t.tokens <- tok
|
||||
}()
|
||||
next.ServeHTTP(w, r)
|
||||
return
|
||||
default:
|
||||
// No immediate token available, need to wait with timer
|
||||
}
|
||||
|
||||
timer := time.NewTimer(t.backlogTimeout)
|
||||
select {
|
||||
case <-timer.C:
|
||||
t.setRetryAfterHeaderIfNeeded(w, false)
|
||||
|
||||
+3
-1
@@ -63,7 +63,9 @@ func URLFormat(next http.Handler) http.Handler {
|
||||
idx += base
|
||||
format = path[idx+1:]
|
||||
|
||||
rctx.RoutePath = path[:idx]
|
||||
if rctx != nil {
|
||||
rctx.RoutePath = path[:idx]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-7
@@ -107,7 +107,8 @@ 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) {
|
||||
if method, rest, found := strings.Cut(pattern, " "); found {
|
||||
if i := strings.IndexAny(pattern, " \t"); i >= 0 {
|
||||
method, rest := pattern[:i], strings.TrimLeft(pattern[i+1:], " \t")
|
||||
mx.Method(method, rest, handler)
|
||||
return
|
||||
}
|
||||
@@ -118,12 +119,7 @@ func (mx *Mux) Handle(pattern string, handler http.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) {
|
||||
if method, rest, found := strings.Cut(pattern, " "); found {
|
||||
mx.Method(method, rest, handlerFn)
|
||||
return
|
||||
}
|
||||
|
||||
mx.handle(mALL, pattern, handlerFn)
|
||||
mx.Handle(pattern, handlerFn)
|
||||
}
|
||||
|
||||
// Method adds the route `pattern` that matches `method` http method to
|
||||
@@ -474,6 +470,9 @@ func (mx *Mux) routeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if supportsPathValue {
|
||||
setPathValue(rctx, r)
|
||||
}
|
||||
if supportsPattern {
|
||||
setPattern(rctx, r)
|
||||
}
|
||||
|
||||
h.ServeHTTP(w, r)
|
||||
return
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//go:build go1.23 && !tinygo
|
||||
// +build go1.23,!tinygo
|
||||
|
||||
package chi
|
||||
|
||||
import "net/http"
|
||||
|
||||
// supportsPattern is true if the Go version is 1.23 and above.
|
||||
//
|
||||
// If this is true, `net/http.Request` has field `Pattern`.
|
||||
const supportsPattern = true
|
||||
|
||||
// setPattern sets the mux matched pattern in the http Request.
|
||||
func setPattern(rctx *Context, r *http.Request) {
|
||||
r.Pattern = rctx.routePattern
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
//go:build !go1.23 || tinygo
|
||||
// +build !go1.23 tinygo
|
||||
|
||||
package chi
|
||||
|
||||
import "net/http"
|
||||
|
||||
// supportsPattern is true if the Go version is 1.23 and above.
|
||||
//
|
||||
// If this is true, `net/http.Request` has field `Pattern`.
|
||||
const supportsPattern = false
|
||||
|
||||
// setPattern sets the mux matched pattern in the http Request.
|
||||
//
|
||||
// setPattern is only supported in Go 1.23 and above so
|
||||
// this is just a blank function so that it compiles.
|
||||
func setPattern(rctx *Context, r *http.Request) {}
|
||||
+2
-13
@@ -650,11 +650,9 @@ func (n *node) routes() []Route {
|
||||
if h.handler == nil {
|
||||
continue
|
||||
}
|
||||
m := methodTypString(mt)
|
||||
if m == "" {
|
||||
continue
|
||||
if m, ok := reverseMethodMap[mt]; ok {
|
||||
hs[m] = h.handler
|
||||
}
|
||||
hs[m] = h.handler
|
||||
}
|
||||
|
||||
rt := Route{subroutes, hs, p}
|
||||
@@ -788,15 +786,6 @@ func longestPrefix(k1, k2 string) int {
|
||||
return i
|
||||
}
|
||||
|
||||
func methodTypString(method methodTyp) string {
|
||||
for s, t := range methodMap {
|
||||
if method == t {
|
||||
return s
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type nodes []*node
|
||||
|
||||
// Sort the list of nodes by label
|
||||
|
||||
Reference in New Issue
Block a user