Created
June 23, 2019 12:21
-
-
Save tonespy/c18c872d142db051fb08a3d17f3a9de3 to your computer and use it in GitHub Desktop.
Revisions
-
tonespy created this gist
Jun 23, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ /* Route is a struct for handling all routes */ type Route struct { Name string Method string Path string HandlerFunction httprouter.Handle } // NewRouter is a helper function for creating new routes func NewRouter(routes []Route) *httprouter.Router { if len(routes) <= 0 { return nil } router := httprouter.New() for _, route := range routes { handle := app.Logger(route.HandlerFunction) router.Handle(route.Method, route.Path, handle) } return router }