我刚刚学习了如何使用httprouter go包,并阅读了许多关于它的文档,但是当涉及到索引页面模板时,我没有使用传递参数toe模板的名称样式。
例如。
我的路由器代码:
func getRouter() *httprouter.Router {
// Load and parse templates (from binary or disk)
templateBox = rice.MustFindBox("templates")
templateBox.Walk("", newTemplate)
// mux handler
router := httprouter.New()
// Example route that encounters an error
router.GET("/broken/handler", broken)
// Index route
router.GET("/:email", index)
router.GET("/read/all", readingHandler)
router.POST("/submit/newcon", Handler1)
router.POST("/read/newcon", Handler2)
// Serve static assets via the "static" directory
fs := rice.MustFindBox("static").HTTPBox()
router.ServeFiles("/static/*filepath", fs)
return router
},那么我得到了一个错误:
恐慌:通配符段:电子邮件与现有路径中的子程序冲突/:电子邮件
发布于 2020-09-20 00:47:53
因此,它应该使用/user/:email,而不仅仅是/:email。
https://stackoverflow.com/questions/63971294
复制相似问题