-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Root static resource router not supported #2846
Comments
your code snip is not runnable with the error "undeclared name: api" |
Sorry, this should work package route
import (
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
var app = gin.Default()
app.Group("/api").GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
app.StaticFS("/", gin.Dir("dist", false))
app.Run(":8080")
} |
Basically, you can't use gin like this and the panic error message already describes your problem. This problem occurs mainly because many golang frameworks use httprouter as their routing module. httprouter uses explicit matching for performance optimization, which causes many wildcards to conflict with specific routes.
I recommend you don't use the root path to serve your static files. you may find some other similar issues like #1301 |
But according to #2663 , this issue should be been solved |
Description
This is a follow up of the issue: #2537
How to reproduce
Expectations
Actual result
Environment
1.17
v1.7.4
MacOS 10.15.7
The text was updated successfully, but these errors were encountered: