Mercurial > gemma
comparison controllers/routes.go @ 226:63dd5216eee4
Refactored gemma server to be more REST-like.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 26 Jul 2018 12:24:30 +0200 |
parents | |
children | 694f959ba3e7 |
comparison
equal
deleted
inserted
replaced
225:8b9cae6d3a21 | 226:63dd5216eee4 |
---|---|
1 package controllers | |
2 | |
3 import ( | |
4 "net/http" | |
5 | |
6 "gemma.intevation.de/gemma/auth" | |
7 | |
8 "github.com/gorilla/mux" | |
9 ) | |
10 | |
11 func BindRoutes(m *mux.Router) { | |
12 | |
13 api := m.PathPrefix("/api").Subrouter() | |
14 | |
15 sysAdmin := auth.EnsureRole("sys_admin") | |
16 | |
17 api.Handle("/users", sysAdmin(createUser)).Methods(http.MethodPost) | |
18 | |
19 api.HandleFunc("/login", token). | |
20 Methods(http.MethodGet, http.MethodPost) | |
21 api.Handle("/logout", auth.SessionMiddleware(http.HandlerFunc(token))). | |
22 Methods(http.MethodGet, http.MethodPost) | |
23 api.Handle("/renew", auth.SessionMiddleware(http.HandlerFunc(renew))). | |
24 Methods(http.MethodGet, http.MethodPost) | |
25 | |
26 } |