Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: http.ServerMux, paths ending in * wildcard are not recognized. #68856

Closed
tatang26 opened this issue Aug 13, 2024 · 3 comments
Closed

Comments

@tatang26
Copy link

Go version

go version go1.23rc2 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/tatan/Library/Caches/go-build'
GOENV='/Users/tatan/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/tatan/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/tatan/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23rc2'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/tatan/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/tatan/code/playground/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/t_/vwcgfn5j3p7dy1y6t4fb1f740000gn/T/go-build1796478944=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

In Go 1.23, it appears that http.ServeMux is not interpreting correctly the * character as a wildcard in route patterns. Instead, * is being treated as a literal path segment, which leads to unexpected behavior. For instance, I have this route

r.HandleFunc("/public/*", assetsHandler)

And when I make a call like:

curl http://localhost:3000/public/image.jpeg

What did you see happen?

I expect the file is served in my web app

What did you expect to see?

I get a 404 page not found

but if I make a request like:

In Go.122 works well

@tatang26 tatang26 changed the title net/http: Paths with * wildcard are not being net/http: http.ServerMux, paths ended in * wildcard are not recognized Aug 13, 2024
@tatang26 tatang26 changed the title net/http: http.ServerMux, paths ended in * wildcard are not recognized net/http: http.ServerMux, paths ending in * wildcard are not recognized. Aug 13, 2024
@seankhliao
Copy link
Member

Nowhere in the go docs is * suggested as a wildcard.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2024
@tatang26
Copy link
Author

Thanks @seankhliao !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants