gin 路由器 404 上带有 :id 参数的 url 模式

问题描述 投票:0回答:1

我从 URL 模式中收到 404 错误,其中包含一个非常简单的参数。

我正在将 gin-gonic 与 golang 一起使用。

这是我的主要节目。我已经删除了所有其他路由来隔离问题。

func main() {
    r := gin.Default()

    r.GET("/action/:id", controllers.ActionHandler)
    r.GET("/home", controllers.Home)

    config.Init()

    r.LoadHTMLGlob("./templates/*/*")

    // routes.AuthRoutes(r)
    
    r.Run("localhost:8080")
}

程序运行时,浏览器识别出

"/home"
。 但它不认识
"/action/demand"

我很困惑

go routes go-gin
1个回答
0
投票

这似乎是 Firefox 缓存问题。很难可靠地重现,因为它有时会发生,但并非总是发生。

症状是浏览器重定向到

"/"' and reports a 404 'page not found' in response to the URL 
“/action/demand”`。

如果我清除 Firefox 缓存,这个问题就会消失。但随后又复发了。

该问题似乎只发生在 Firefox 上

除了使用其他浏览器之外,我还没有找到解决方法。

© www.soinside.com 2019 - 2024. All rights reserved.