Skip to content

add adapter function to wrap http.HandleFunc and http.Handle into a handle#381

Open
ducknificient wants to merge 1 commit into
julienschmidt:masterfrom
ducknificient:master
Open

add adapter function to wrap http.HandleFunc and http.Handle into a handle#381
ducknificient wants to merge 1 commit into
julienschmidt:masterfrom
ducknificient:master

Conversation

@ducknificient
Copy link
Copy Markdown

while HandlerFunc able to convert default http.HandlerFunc to router, this additional adapter function for better code organizing, example in the router.GET or router.POST can accept http.HandlerFunc.

router.OPTIONS("/*path", httprouter.WrapF(controller.DoOPTIONS))
router.GET("/example/get", httprouter.WrapF(controller.DoGET))
router.POST("/example/post",httprouter.WrapF(controller.DoPOST))

thanks, best regards

Copy link
Copy Markdown

@themavik themavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WrapF / WrapH adapters map http.HandlerFunc / http.Handler into Handle without extra boilerplate. nit: the WrapH godoc line still says WrapF—rename that comment to match the symbol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants