httphelpers

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: BSD-2-Clause Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatusCode

func StatusCode(ctx context.Context, err error) int

StatusCode returns the status code of the error

Types

type Client

type Client struct {
	Binding    *bindingHandler
	Middleware *middlewareHandler
	Rendering  *renderingHandler
	TLS        *tlsHandler
	Server     *serverHandler
	Validator  *validatorHandler
	// contains filtered or unexported fields
}

Client is the client object for httphelpers

func New

func New(ctx context.Context, tracer *trace.Tracer, cfg *model.Cfg, log *logger.Log) (*Client, error)

New creates a new httphelpers client

type DefaultValidator

type DefaultValidator struct {
	Validate *validator.Validate
}

DefaultValidator is the default validator for httphelpers

func (*DefaultValidator) Engine

func (v *DefaultValidator) Engine() any

Engine satisfy the binding.Validator interface

func (*DefaultValidator) ValidateStruct

func (v *DefaultValidator) ValidateStruct(obj any) error

ValidateStruct satisfies the binding.StructValidator interface

type JWKSCache

type JWKSCache interface {
	Get(ctx context.Context, key string) ([]byte, bool)
	Set(ctx context.Context, key string, value []byte)
}

JWKSCache is the generic cache interface used to store raw JWKS JSON. It is satisfied by both MemoryCache and MongoCache from pkg/cache.

type RateLimiter

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

RateLimiter implements a token bucket rate limiter using gin-ratelimit

func (*RateLimiter) Middleware

func (rl *RateLimiter) Middleware() gin.HandlerFunc

Middleware returns a Gin middleware handler that enforces rate limiting by IP

type SafeEngine

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

SafeEngine wraps a SPOCP AdaptiveEngine with a sync.RWMutex so that concurrent request handlers can safely call QueryElement while still allowing future rule hot-reloading under a write lock.

func (*SafeEngine) QueryElement

func (s *SafeEngine) QueryElement(q sexp.Element) bool

QueryElement checks if the query is authorized (read-locked).

func (*SafeEngine) RuleCount

func (s *SafeEngine) RuleCount() int

RuleCount returns the number of loaded rules (read-locked).

Jump to

Keyboard shortcuts

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