Guest User

Untitled

a guest
Feb 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. ```go
  2. import (
  3. mwr "github.com/gilcrest/go-API-template/pkg/api/server/middleware"
  4. "github.com/gilcrest/go-API-template/pkg/env"
  5. "github.com/gorilla/mux"
  6. )
  7.  
  8. // Dispatch is a way of organizing routing to handlers (versioning as well)
  9. func Dispatch(env *env.Env, rtr *mux.Router) *mux.Router {
  10.  
  11. // initialize new instance of APIAudit
  12. audit := new(mwr.APIAudit)
  13.  
  14. // match only POST requests on /api/v1/appUser/create
  15. rtr.Handle("/v1/appUser", mwr.Adapt(Handler{env, CreateUserHandler},
  16. mwr.LogRequest(env, audit),
  17. mwr.LogResponse(env, audit))).
  18. Methods("POST").
  19. Headers("Content-Type", "application/json")
  20.  
  21. return rtr
  22. }
  23. ```
Add Comment
Please, Sign In to add comment