Created
April 20, 2017 22:28
-
-
Save hashbender/aa8ea6f2d7624bc6ae9959394f1c82b8 to your computer and use it in GitHub Desktop.
Complete NewRouter
This file contains 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 characters
//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