middleware

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2022 License: ISC Imports: 12 Imported by: 0

Documentation

Overview

Package middleware defines all the middlewares for the application

Index

Constants

View Source
const SessionIDKey = "SessionID"

SessionIDKey is the key used to set and get the session id in the context of the current request

View Source
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 Cache

func Cache(maxAge int) gin.HandlerFunc

Cache middleware sets the Cache-Control header

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL