view controllers/routes.go @ 227:6620b5f649f8

Login controller is now called with POST to /login.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 26 Jul 2018 12:36:35 +0200
parents 63dd5216eee4
children 694f959ba3e7
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(createUser)).Methods(http.MethodPost)

	api.HandleFunc("/login", token).
		Methods(http.MethodGet, http.MethodPost)
	api.Handle("/logout", auth.SessionMiddleware(http.HandlerFunc(token))).
		Methods(http.MethodGet, http.MethodPost)
	api.Handle("/renew", auth.SessionMiddleware(http.HandlerFunc(renew))).
		Methods(http.MethodGet, http.MethodPost)

}