Mercurial > gemma
view controllers/routes.go @ 274:4d37c8646123
chore: .hgignore updated
In order to prevent accidential commits of gemma, session.data or buildbase sources
those excluded in .hgignore
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 30 Jul 2018 12:59:01 +0200 |
parents | de6fdb316b8f |
children | d1b0d964af09 |
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{ Handle: listUser, })).Methods(http.MethodGet) 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) }