0
我在我的Go项目中使用https://github.com/julienschmidt/httprouter。httprouter设置自定义NotFound
我问了一会儿这个问题,这是由@icza解决:httprouter configuring 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)
我的功能是这样的:
以前有一些在过去的几个星期内打破了这个软件包的变化因为我无法弄清楚为什么我在一个项目中发现错误而不是在另一个项目中发生错误?