middleware

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIErrorResponse added in v1.19.0

func APIErrorResponse(w http.ResponseWriter, status int, message string)

APIErrorResponse represents a standardized API error response

func CallCostMiddleware added in v1.19.0

func CallCostMiddleware(next http.Handler) http.Handler

CallCostMiddleware sets call costs based on endpoint mapping

func CorsMiddleware

func CorsMiddleware(next http.Handler) http.Handler

func GetCallCost added in v1.19.0

func GetCallCost(r *http.Request) int

GetCallCost extracts the call cost from request context, defaults to 1

func GetClientIP added in v1.19.0

func GetClientIP(r *http.Request) string

GetClientIP extracts the real client IP from the request

func GetTokenInfo added in v1.19.0

func GetTokenInfo(r *http.Request) *types.APITokenInfo

GetTokenInfo extracts token information from request context

func SetEndpointCost added in v1.19.0

func SetEndpointCost(path string, cost int)

SetEndpointCost sets the call cost for a specific endpoint path

Types

type RateLimitMiddleware added in v1.19.0

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

RateLimitMiddleware handles rate limiting for API requests

func NewRateLimitMiddleware added in v1.19.0

func NewRateLimitMiddleware() *RateLimitMiddleware

NewRateLimitMiddleware creates a new rate limiting middleware instance

func (*RateLimitMiddleware) Middleware added in v1.19.0

func (m *RateLimitMiddleware) Middleware(next http.Handler) http.Handler

Middleware applies rate limiting to API requests

type TokenAuthMiddleware added in v1.19.0

type TokenAuthMiddleware struct{}

TokenAuthMiddleware handles JWT token authentication for API requests

func NewTokenAuthMiddleware added in v1.19.0

func NewTokenAuthMiddleware() *TokenAuthMiddleware

NewTokenAuthMiddleware creates a new token authentication middleware instance

func (*TokenAuthMiddleware) Middleware added in v1.19.0

func (m *TokenAuthMiddleware) Middleware(next http.Handler) http.Handler

Middleware processes JWT authentication and adds token info to request context

Jump to

Keyboard shortcuts

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