-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Wildcard route conflicts with static files #360
Comments
@nazwa the problem is not The conflict happens because: /assets would match HttpRouter developer is working in a non-strict mode that will allow this to work. Workaround: r.GET("/c/:code", p.redirectHandler) |
I thought placeholders only matched up to the first slash in the path? Are you saying that |
I also faced the same issue. The root of the issue is the used router https://github.com/julienschmidt That issue is well known and not fixed since a year julienschmidt/httprouter#210 I don't know why gin use this buggy router implementation there are some great alternatives |
Confirm. My problem:
I don't see any possibility how The line:
|
Is there another solution? |
I have an issue with this as well. router.Static("/", "./static")
router.GET("/socket.io/", gin.WrapH(server))
router.POST("/socket.io/", gin.WrapH(server)) This works with many other routers but not with Gin! :( I want to serve the directory
Is there going to be a better way of handling conflicts or is it possible to use a different router? How am I supposed to go about this? I get this error, by the way:
There are two workarounds that seem to work: router.StaticFile("/", "static/index.html")
router.StaticFile("/js/socket.io.js", "static/js/socket.io.js")
router.GET("/socket.io/", gin.WrapH(server))
router.POST("/socket.io/", gin.WrapH(server)) and: router.GET("/", func(c *gin.Context) {
c.Redirect(http.StatusMovedPermanently, "public/")
})
router.GET("/socket.io/", gin.WrapH(server))
router.POST("/socket.io/", gin.WrapH(server))
router.StaticFS("/public", http.Dir("./static")) |
router.NoRoute(gin.WrapH(http.FileServer(http.Dir("static"))))
router.GET("/socket.io/", gin.WrapH(server))
router.POST("/socket.io/", gin.WrapH(server)) |
Just found an interesting issue:
Generates:
Seems like it's due to the fact that Static uses *filename wildcard. My plane is due in soon, so can't dig into it now, but I think any static wildcards should be generated below the url path specified, not within root domain.
Any thoughts?
The text was updated successfully, but these errors were encountered: