Documentation ¶
Overview ¶
Package middleware defines all the middlewares for the application
Index ¶
Constants ¶
const SessionIDKey = "SessionID"
SessionIDKey is the key used to set and get the session id in the context of the current request
const UserIDKey = "UserID"
UserIDKey is the key used to set and get the user id in the context of the current request
Variables ¶
This section is empty.
Functions ¶
func Auth ¶
func Auth() gin.HandlerFunc
Auth middleware redirects to /login and aborts the current request if there is no authenticated user
func General ¶
func General() gin.HandlerFunc
General handles the default headers that should be present in every response
func NoAuth ¶
func NoAuth() gin.HandlerFunc
NoAuth is for routes that can only be accessed when the user is unauthenticated
func Sensitive ¶
func Sensitive() gin.HandlerFunc
Sensitive middleware handles headers that should be set for routes that may contain sensitive data such as personal information
func Session ¶
func Session(db *gorm.DB) gin.HandlerFunc
Session middleware checks for an active session and sets the UserIDKey to the context of the current request if found
func Throttle ¶
func Throttle(limit int) gin.HandlerFunc
Throttle middleware takes a limit per minute and blocks any additional requests that go over this limit
Types ¶
This section is empty.