view controllers/routes.go @ 233:531d1f8a2b4b

Fix spelling
author Tom Gottfried <tom@intevation.de>
date Thu, 26 Jul 2018 15:02:19 +0200
parents 694f959ba3e7
children 7d1f0ffdfa41
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", 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)

}