-
-
Notifications
You must be signed in to change notification settings - Fork 555
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
chi: wildcard '*' must be the last value in a route. trim trailing text or use a '{param}' instead #3357
Comments
I have the same problem, tested on version 3.7.2 and it works fine:
package design
import . "goa.design/goa/v3/dsl"
var _ = Service("swagger", func() {
Files("/swagger-ui/index.html", "public/swagger/index.html", func() {
Description("Serve home page.")
Docs(func() {
Description("Additional documentation")
URL("https://goa.design")
})
})
Files("/swagger-ui/{*path}", "public/swagger", func() {
Description("Serve static content.")
})
Meta("swagger:generate", "false")
}) output:
All stuff regarding the path module is missing. |
This happened to me after upgrading goa.
There was a change in routers
So the solution is to downgrade. Here is the chi example file server. It is expecting the user to perform a prefix strip. |
This problem is reproduced in examples/files with modifying design/design.go like this: index aba49c1f..5ebde889 100644
--- a/files/design/design.go
+++ b/files/design/design.go
@@ -5,8 +5,5 @@ import (
)
var _ = Service("openapi", func() {
- Files("/openapi.json", "gen/http/openapi.json")
- Files("/openapi.yaml", "gen/http/openapi.yaml")
- Files("/openapi3.json", "gen/http/openapi3.json")
- Files("/openapi3.yaml", "gen/http/openapi3.yaml")
+ Files("/static/{*path}", "gen/http")
}) After modifying design/design.go, you can see the error with the following steps.
on v3.13.1 (Error on starting server)
on v3.12.4 (OK)
I'd like to know how to handle static files by dsl.Files function with wildcard on v3.13.0 or later. FYI: using dsl.Files with "/static/*"Modifying design/design.go like this: package design
import (
. "goa.design/goa/v3/dsl"
)
var _ = Service("openapi", func() {
Files("/static/*", "gen/http")
}) the server starts without errors, but it returns 301 for existing file
|
chi router was introduced in this PR. I believe this needs to be fixed in the generator by generating different code. For chi it needs to strip a prefix. Some experimentation would be needed to determine how to best generate code in a backwards compatible way. Another possibility is rolling back the upgrade to chi. Some direction from @raphael on how to approach fixing this would be useful. If you need to use GOA 3.13.1 and need this feature the only approach I know of is to make an out of band file server that is not generated by the GOA DSL. This should be straightforward, and can be added to your http.go, but it won't show up in the OpenAPI description unless it can be setup to override the route that is being generated by GOA. |
This was indeed a regression introduced with the change to chi. This is fixed by #3374. Thank you for the nice repro! |
I confirmed that the problem was fixed. Thank you! @raphael server
curl
|
'panic: chi: wildcard '*' must be the last value in a route. trim trailing text or use a '{param}' instead
I have a problem with new version in goa.design v3.13.0:
It occurs when trying to mount the service.
swaggersvr.Mount(mux, swaggerServer)
The text was updated successfully, but these errors were encountered: