Skip to content

Instantly share code, notes, and snippets.

@hashbender
Created April 20, 2017 22:28
Show Gist options
  • Save hashbender/aa8ea6f2d7624bc6ae9959394f1c82b8 to your computer and use it in GitHub Desktop.
Save hashbender/aa8ea6f2d7624bc6ae9959394f1c82b8 to your computer and use it in GitHub Desktop.
Complete NewRouter
//NewRouter returns a new Gorrila Mux router
func NewRouter(c AppContext) *mux.Router {
router := mux.NewRouter().StrictSlash(true)
appContext = c
for _, route := range routes {
//Check all routes to make sure the users are properly authenticated
router.
Methods(route.Method...).
Path(route.Pattern).
Name(route.Name).
Handler(CheckAuth(SetContentTypeText(route.ContextedHandler)))
}
return router
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment