is it possible to get the registered path?

Author: yumxuCreated Mar 9, 2022Updated Jun 27, 2024

I'm about to use httprouter in a http api gateway, and use httprouter to match path. i do not need a handle function, so i register paths with an empty handler:

router := httprouter.New()
router.Handle("GET","/user/:user_id/basic", func(writer http.ResponseWriter,
			request *http.Request, params httprouter.Params) {})
router.Handle("GET","/user/:user_id/feature", func(writer http.ResponseWriter,
			request *http.Request, params httprouter.Params) {})

then use LookUp method to match path

router.LookUp("GET","/user/1234/basic")

the LookUp method only returns handler, params and tsr currently. what i need is the matched path /user/:user_id/basic to get the upstream server which is related to the path.

Source: julienschmidt/httprouter