Merge pull request #133 from joeatwork/stricter-url-endpoints

server: user management endpoints strictly conform to schema
This commit is contained in:
Joe Bowers 2015-09-24 17:03:00 -07:00
commit e8f347a738
2 changed files with 6 additions and 4 deletions

View file

@ -244,7 +244,7 @@ func (s *Server) HTTPHandler() http.Handler {
mux.Handle(path.Join(apiBasePath, clientPath), s.NewClientTokenAuthHandler(clientHandler))
usersAPI := usersapi.NewUsersAPI(s.UserManager, s.ClientIdentityRepo, s.UserEmailer, s.localConnectorID)
mux.Handle(path.Join(apiBasePath, UsersSubTree)+"/", NewUserMgmtServer(usersAPI, s.JWTVerifierFactory(), s.UserManager, s.ClientIdentityRepo).HTTPHandler())
mux.Handle(path.Join(apiBasePath, UsersSubTree), NewUserMgmtServer(usersAPI, s.JWTVerifierFactory(), s.UserManager, s.ClientIdentityRepo).HTTPHandler())
return http.Handler(mux)
}

View file

@ -24,8 +24,8 @@ const (
var (
UsersSubTree = "/users"
UsersListEndpoint = addBasePath(UsersSubTree) + "/"
UsersCreateEndooint = addBasePath(UsersSubTree)
UsersListEndpoint = addBasePath(UsersSubTree)
UsersCreateEndpoint = addBasePath(UsersSubTree)
UsersGetEndpoint = addBasePath(UsersSubTree + "/:id")
)
@ -47,8 +47,10 @@ func NewUserMgmtServer(userMgmtAPI *api.UsersAPI, jwtvFactory JWTVerifierFactory
func (s *UserMgmtServer) HTTPHandler() http.Handler {
r := httprouter.New()
r.RedirectTrailingSlash = false
r.RedirectFixedPath = false
r.GET(UsersListEndpoint, s.listUsers)
r.POST(UsersCreateEndooint, s.createUser)
r.POST(UsersCreateEndpoint, s.createUser)
r.GET(UsersGetEndpoint, s.getUser)
return r
}