Bump minimum Go to 1.23, always use request.Pattern (#1048)
Go 1.26 is out now so we can bump our minimum Go to 1.23
This commit is contained in:
parent
3328d4d3ab
commit
a54874f0e2
5 changed files with 3 additions and 38 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
|
@ -20,7 +20,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.22.x, 1.23.x, 1.24.x, 1.25.x, 1.26.x]
|
||||
go-version: [1.23.x, 1.24.x, 1.25.x, 1.26.x]
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -2,4 +2,4 @@ module github.com/go-chi/chi/v5
|
|||
|
||||
// Chi supports the four most recent major versions of Go.
|
||||
// See https://github.com/go-chi/chi/issues/963.
|
||||
go 1.22
|
||||
go 1.23
|
||||
|
|
|
|||
4
mux.go
4
mux.go
|
|
@ -472,9 +472,7 @@ func (mx *Mux) routeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
value := rctx.URLParams.Values[i]
|
||||
r.SetPathValue(key, value)
|
||||
}
|
||||
if supportsPattern {
|
||||
setPattern(rctx, r)
|
||||
}
|
||||
r.Pattern = rctx.routePattern
|
||||
|
||||
h.ServeHTTP(w, r)
|
||||
return
|
||||
|
|
|
|||
16
pattern.go
16
pattern.go
|
|
@ -1,16 +0,0 @@
|
|||
//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
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
//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) {}
|
||||
Loading…
Reference in a new issue