-
-
Save orbitalmedia/618e9218b5f0a66fe495d1b77d49d9ed to your computer and use it in GitHub Desktop.
Revisions
-
Peter Greczner revised this gist
Aug 24, 2014 . 1 changed file with 2 additions and 2 deletions.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 @@ -28,8 +28,8 @@ func NegroniRoute(m *mux.Router, base string, path string, pathType string, f func(http.ResponseWriter, *http.Request), // Your Route Handler mids ...func(http.ResponseWriter, *http.Request, http.HandlerFunc) // Middlewares ) { _routes := mux.NewRouter() _routes.HandleFunc(base+path, f).Methods(pathType) -
Peter Greczner revised this gist
Aug 24, 2014 . 1 changed file with 7 additions and 0 deletions.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 @@ -6,7 +6,14 @@ import ( ) func main() { router := mux.NewRouter() apiV1 := router.PathPrefix("/api/v1").Subrouter() NegroniRouter(apiV1, "/api/v1", "/users/create", "POST", externalLib.CreateUser, externalAuthLib.Authorize) n := negroni.Classic() n.UseHandler(router) n.Run(":3000") } /* Generates a negroni handler for the route: -
Peter Greczner revised this gist
Aug 24, 2014 . 1 changed file with 36 additions and 1 deletion.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 @@ -1 +1,36 @@ package main import ( "github.com/codegangsta/negroni" "github.com/gorilla/mux" ) func main() { } /* Generates a negroni handler for the route: pathType (base+string) which is handled by `f` and passed through middleware `mids` sequentially. ex: NegroniRoute(router, "/api/v1", "/users/update", "POST", UserUpdateHandler, LoggingMiddleware, AuthorizationMiddleware) */ func NegroniRoute(m *mux.Router, base string, path string, pathType string, f func(http.ResponseWriter, *http.Request), mids ...func(http.ResponseWriter, *http.Request, http.HandlerFunc) ) { _routes := mux.NewRouter() _routes.HandleFunc(base+path, f).Methods(pathType) _n := negroni.New() for i: range(mids) { _n.Use(negroni.HandlerFunc(mids[i])) } _n.UseHandler(_routes) m.Handle(path, _n) } -
Peter Greczner created this gist
Aug 24, 2014 .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 @@ package main