middlewares

package
v0.0.0-...-4d30d97 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddleware

func CORSMiddleware(next http.Handler) http.Handler

CORS headers to allow web browser testing TODO: Mejorar seguridad para prod (o sacar)

func GetUserIDFromContext

func GetUserIDFromContext(ctx context.Context) ([]uint8, error)

func LoggingMiddleware

func LoggingMiddleware(next http.Handler) http.Handler

func NewAuditMiddleware

func NewAuditMiddleware() func(http.Handler) http.Handler

func RecoveryMiddleware

func RecoveryMiddleware(next http.Handler) http.Handler

Types

type ContextKey

type ContextKey string
var UserKey ContextKey = "userId"

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

func NewAuthMiddleware

func NewAuthMiddleware(permissionService PermissionService, userService UserService, auditService audit.AuditService) *Middleware

func (*Middleware) RequireAuthAndPermission

func (m *Middleware) RequireAuthAndPermission(permissions []string, useRefreshToken bool) func(http.HandlerFunc) http.HandlerFunc

type PermissionService

type PermissionService interface {
	UserHasPermissions(permissionNames []string, userId []uint8) (bool, error)
}

type UserService

type UserService interface {
	UserExist(userId []uint8) (bool, error)
}

Jump to

Keyboard shortcuts

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