From 02b29fe33d725ef02d1b152a03f068411efd67fa Mon Sep 17 00:00:00 2001 From: Raphael Simon Date: Thu, 28 Sep 2023 22:10:46 -0700 Subject: [PATCH] Update wildcard handling for chi router The upgrade to chi caused a regression for file servers using wildcards. --- http/codegen/server.go | 2 +- http/codegen/testdata/server_init_functions.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/http/codegen/server.go b/http/codegen/server.go index 7cc5a03bec..883bd29f8a 100644 --- a/http/codegen/server.go +++ b/http/codegen/server.go @@ -415,7 +415,7 @@ func {{ .MountHandler }}(mux goahttp.Muxer, h http.Handler) { {{- if .IsDir }} {{- range .RequestPaths }} mux.Handle("GET", "{{ . }}{{if ne . "/"}}/{{end}}", h.ServeHTTP) - mux.Handle("GET", "{{ . }}{{if ne . "/"}}/{{end}}*{{ $.PathParam }}", h.ServeHTTP) + mux.Handle("GET", "{{ . }}{{if ne . "/"}}/{{end}}{*{{ $.PathParam }}}", h.ServeHTTP) {{- end }} {{- else }} {{- range .RequestPaths }} diff --git a/http/codegen/testdata/server_init_functions.go b/http/codegen/testdata/server_init_functions.go index c2a6630480..ee3a31eef6 100644 --- a/http/codegen/testdata/server_init_functions.go +++ b/http/codegen/testdata/server_init_functions.go @@ -235,7 +235,7 @@ func (s *Server) Mount(mux goahttp.Muxer) { var ServerMultipleFilesMounterCode = `// MountPathToFolder configures the mux to serve GET request made to "/". func MountPathToFolder(mux goahttp.Muxer, h http.Handler) { mux.Handle("GET", "/", h.ServeHTTP) - mux.Handle("GET", "/*wildcard", h.ServeHTTP) + mux.Handle("GET", "/{*wildcard}", h.ServeHTTP) } ` @@ -243,7 +243,7 @@ var ServerMultipleFilesWithPrefixPathMounterCode = `// MountPathToFolder configu // "/server_file_server". func MountPathToFolder(mux goahttp.Muxer, h http.Handler) { mux.Handle("GET", "/server_file_server/", h.ServeHTTP) - mux.Handle("GET", "/server_file_server/*wildcard", h.ServeHTTP) + mux.Handle("GET", "/server_file_server/{*wildcard}", h.ServeHTTP) } `