middlewares

package
v0.0.0-...-34add53 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminMiddleware

func AdminMiddleware() gin.HandlerFunc

AdminMiddleware is a middleware that checks if the user is an admin

func AuthMiddleware

func AuthMiddleware() gin.HandlerFunc

AuthMiddleware is a middleware that checks if the user is authenticated

func ParseIDMiddlware

func ParseIDMiddlware() gin.HandlerFunc

ParseIDMiddlware is a middleware function that parses the "id" parameter from the request URL and sets it in the context. If the "id" parameter is not a valid integer, it returns a JSON response with a status code of 400 and an error message. The middleware function is designed to be used with the Gin framework.

func ParsePaginationParams

func ParsePaginationParams() gin.HandlerFunc

ParsePaginationParams is a middleware function that parses the pagination parameters from the request. It extracts the offset and limit values from the request and sets them in the context for further processing. If there is an error while parsing the parameters, it handles the error and aborts the request with a bad request status.

func SanitizeMiddleware

func SanitizeMiddleware() gin.HandlerFunc

SanitizeMiddleware is a middleware that sanitizes input to prevent XSS attacks

func ValidateJSON

func ValidateJSON(obj interface{}) gin.HandlerFunc

Types

type Key

type Key int
const UserClaimsKey Key = iota

Jump to

Keyboard shortcuts

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