middleware

package
v0.0.0-...-c2e6958 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package middleware pkg/api/middleware/http_headers.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adapt

func Adapt(h HandlerFunc, middlewares ...Middleware) gofr.Handler

Adapt converts a HandlerFunc and middlewares into a gofr.Handler

func CustomHeadersMiddleware

func CustomHeadersMiddleware() gofrHTTP.Middleware

func DebugHeadersMiddleware

func DebugHeadersMiddleware() gofrHTTP.Middleware

func GetAuthClaims

func GetAuthClaims(c *gofr.Context) (map[string]string, error)

GetAuthClaims extracts the relevant authentication claims from the custom context

Types

type Handler

type Handler interface {
	Handle(*gofr.Context) (interface{}, error)
}

Handler is an interface that wraps the basic Handle method.

func RequireTenant

func RequireTenant(next Handler) Handler

RequireTenant is a middleware that ensures a tenant ID is present

func RequireUser

func RequireUser(next Handler) Handler

RequireUser is a middleware that ensures a user ID is present

type HandlerFunc

type HandlerFunc func(*gofr.Context) (interface{}, error)

HandlerFunc is a function type that implements the Handler interface.

func (HandlerFunc) Handle

func (f HandlerFunc) Handle(c *gofr.Context) (interface{}, error)

Handle calls f(c).

type Middleware

type Middleware func(Handler) Handler

Middleware defines the standard middleware signature.

func RequireRole

func RequireRole(roles ...string) Middleware

RequireRole is a middleware that checks if the user has any of the required roles

Jump to

Keyboard shortcuts

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