我在 Go 项目中使用https://github.com/julienschmidt/httprouter。
不久前我问了这个问题,@ icza解决了这个问题:httprouter 配置 NotFound但现在,开始一个新项目并使用非常相似的代码,我似乎在控制台中遇到错误。
尝试配置自定义处理程序NotFound,MethodNotAllowed我正在使用:
router.NotFound = customNotFound
router.MethodNotAllowed = customMethodNotAllowed
产生:
cannot use customNotFound (type func(http.ResponseWriter, *http.Request)) as type http.Handler in assignment:
func(http.ResponseWriter, *http.Request) does not implement http.Handler (missing ServeHTTP method)
cannot use customMethodNotAllowed (type func(http.ResponseWriter, *http.Request)) as type http.Handler in assignment:
func(http.ResponseWriter, *http.Request) does not implement http.Handler (missing ServeHTTP method)
我的功能如下所示:
func customNotFound(w http.ResponseWriter, r *http.Request) {
core.WriteError(w, "PAGE_NOT_FOUND", "Requested resource could not be found")
return
}
func customMethodNotAllowed(w http.ResponseWriter, r *http.Request) {
core.WriteError(w, "METHOD_NOT_PERMITTED", "Request method not supported by that resource")
return
}
在过去的几个月里,这个包是否发生了一些重大变化,因为我不知道为什么我在一个项目中而不是在另一个项目中收到错误?
设置自定义图标
微信自定义菜单设置?
echarts:legend添加tooltip,设置forammter,自定义tooltip显示内容,但是不起作用
自定义dialog 设置背景框 圆角
相关分类