Mercurial > gemma
view controllers/routes.go @ 250:deabc2712634
Implemented /users GET as list of users.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 27 Jul 2018 11:05:03 +0200 |
parents | 24eb518b0394 |
children | de6fdb316b8f |
line wrap: on
line source
package controllers import ( "net/http" "gemma.intevation.de/gemma/auth" "github.com/gorilla/mux" ) func BindRoutes(m *mux.Router) { api := m.PathPrefix("/api").Subrouter() sysAdmin := auth.EnsureRole("sys_admin") api.Handle("/users", sysAdmin(&JSONHandler{ Handle: listUsers, })).Methods(http.MethodGet) api.Handle("/users", sysAdmin(&JSONHandler{ Input: func() interface{} { return new(User) }, Handle: createUser, })).Methods(http.MethodPost) api.Handle("/users/{user}", sysAdmin(&JSONHandler{ Input: func() interface{} { return new(User) }, Handle: updateUser, })).Methods(http.MethodPut) api.Handle("/users/{user}", sysAdmin(&JSONHandler{ Handle: deleteUser, })).Methods(http.MethodDelete) api.HandleFunc("/login", login). Methods(http.MethodGet, http.MethodPost) api.Handle("/logout", auth.SessionMiddleware(http.HandlerFunc(logout))). Methods(http.MethodGet, http.MethodPost) api.Handle("/renew", auth.SessionMiddleware(http.HandlerFunc(renew))). Methods(http.MethodGet, http.MethodPost) }