Mercurial > gemma
view controllers/routes.go @ 249:e0f47d9ebde0
Hotfix: changed login call back to GET from POST.
For some reason POST didn't work as intended: the credentials were not
send... This is only a workaround, as POST would still be the right
way to go...
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Fri, 27 Jul 2018 11:04:20 +0200 |
parents | 24eb518b0394 |
children | deabc2712634 |
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{ 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) }