Documentation ¶
Overview ¶
Package middleware is responsible for the definition/implementation of middleware functionality. This package will also handle maintaining request Context and Session.
Index ¶
- Variables
- func CSRFExceptions(handler http.Handler) http.HandlerFunc
- func GetContext(handler http.Handler) http.HandlerFunc
- func JSONError(w http.ResponseWriter, c int, m string)
- func RequireAPIKey(handler http.Handler) http.HandlerFunc
- func RequireIP(ip string) func(http.Handler) http.HandlerFunc
- func RequireLimitedAccessKey(handler http.Handler) http.HandlerFunc
- func RequireLogin(handler http.Handler) http.HandlerFunc
- func RequireRoles(rids []int64) func(http.Handler) http.HandlerFunc
- func SSO(handler http.Handler) http.HandlerFunc
Constants ¶
This section is empty.
Variables ¶
var CSRFExemptPrefixes = []string{
"/api",
}
Functions ¶
func CSRFExceptions ¶
func CSRFExceptions(handler http.Handler) http.HandlerFunc
func GetContext ¶
func GetContext(handler http.Handler) http.HandlerFunc
GetContext wraps each request in a function which fills in the context for a given request. This includes setting the User and Session keys and values as necessary for use in later functions.
func JSONError ¶
func JSONError(w http.ResponseWriter, c int, m string)
JSONError returns an error in JSON format with the given status code and message
func RequireAPIKey ¶
func RequireAPIKey(handler http.Handler) http.HandlerFunc
func RequireLimitedAccessKey ¶
func RequireLimitedAccessKey(handler http.Handler) http.HandlerFunc
func RequireLogin ¶
func RequireLogin(handler http.Handler) http.HandlerFunc
RequireLogin is a simple middleware which checks to see if the user is currently logged in. If not, the function returns a 302 redirect to the login page.
func RequireRoles ¶
func RequireRoles(rids []int64) func(http.Handler) http.HandlerFunc
RequireRoles enforces user role id to be one among the given role ids
Types ¶
This section is empty.