Documentation
¶
Index ¶
- func APIErrorResponse(w http.ResponseWriter, status int, message string)
- func CallCostMiddleware(next http.Handler) http.Handler
- func CorsMiddleware(next http.Handler) http.Handler
- func GetCallCost(r *http.Request) int
- func GetClientIP(r *http.Request) string
- func GetTokenInfo(r *http.Request) *types.APITokenInfo
- func SetEndpointCost(path string, cost int)
- type RateLimitMiddleware
- type TokenAuthMiddleware
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
CallCostMiddleware sets call costs based on endpoint mapping
func GetCallCost ¶ added in v1.19.0
GetCallCost extracts the call cost from request context, defaults to 1
func GetClientIP ¶ added in v1.19.0
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
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