【发布时间】:2015-04-05 17:27:09
【问题描述】:
我有以下路线:
router.Methods("POST").Path("/my_post_01").HandlerFunc(myHandler1)
router.Methods("GET").Path("/my_get_01").HandlerFunc(myHandler2)
router.Methods("POST").Path("/my_post_02").HandlerFunc(myHandler3)
router.Methods("GET").Path("/my_get_02").HandlerFunc(myHandler4)
router.Methods("POST").Path("/my_post_03").HandlerFunc(myHandler5)
router.Methods("GET").Path("/my_get_03").HandlerFunc(myHandler6)
router.Methods("POST").Path("/my_post_04").HandlerFunc(myHandler7)
router.Methods("GET").Path("/my_get_04").HandlerFunc(myHandler8)
router.Methods("POST").Path("/my_post_05").HandlerFunc(myHandler9)
router.Methods("GET").Path("/my_get_05").HandlerFunc(myHandler10)
随着我的路线越来越多,管理起来变得越来越困难。
我想做这样的事情:
router.Path("/my/*").HandleFunc(mypackage.RegisterHandler)
所有处理程序都在另一个包中分开
有什么方法可以在单独的包中匹配这些路径?
谢谢,
【问题讨论】:
-
...你试过你放在这里的东西吗?没有什么可以阻止您将位于另一个包中的
http.HandlerFunc传递给您的路由器...
标签: go httphandler gorilla servemux