Documentation ¶
Index ¶
- func Authentication(next http.Handler) http.Handler
- func BasicAuth(expectedUsername, expectedPassword string) func(http.Handler) http.Handler
- func CORS(next http.Handler) http.Handler
- func OtelHTTP(operation string) func(h http.Handler) http.Handler
- func RESTChainID(acceptedChainIDs []tableland.ChainID) func(next http.Handler) http.Handler
- func RateLimitController(cfg RateLimiterConfig) (mux.MiddlewareFunc, error)
- func TraceID(next http.Handler) http.Handler
- func WithLogging(h http.Handler) http.Handler
- type ContextKey
- type RateLimiterConfig
- type RateLimiterRouteConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authentication ¶
Authentication is middleware that provides JWT authentication.
func BasicAuth ¶
BasicAuth is middleware that checks the expected username and password match the http basic auth values.
func RESTChainID ¶
RESTChainID adds to the request context the {chainID} that must be present in the REST path.
func RateLimitController ¶
func RateLimitController(cfg RateLimiterConfig) (mux.MiddlewareFunc, error)
RateLimitController creates a new middleware to rate limit requests. It applies a priority based rate limiting key for the rate limiting: 1. A "chain-address" was detected (i.e: via a signed SIWE). 2. If 1. isn't present, it will use an existing X-Forwarded-For IP included by a load-balancer in the infrastructure. 3. If 2. isn't present, it will use the connection remote address.
Types ¶
type ContextKey ¶
type ContextKey int
ContextKey is used to key context values.
const ( // ContextKeyAddress is used to store the address of the client for the incoming request. ContextKeyAddress ContextKey = iota // ContextKeyChainID is used to store the chain id of the client for the incoming request. ContextKeyChainID ContextKey = iota // ContextIPAddress is used to store the ip address of the client for the incoming request. ContextIPAddress ContextKey = iota )
type RateLimiterConfig ¶
type RateLimiterConfig struct { Default RateLimiterRouteConfig JSONRPCRoute string JSONRPCMethodLimits map[string]RateLimiterRouteConfig }
RateLimiterConfig specifies a default rate limiting configuration, and optional custom rate limiting rules for a JSON RPC sub-route with path JSONRPCRoute. i.e: particular JSON RPC methods can have different rate limiting.
type RateLimiterRouteConfig ¶
RateLimiterRouteConfig specifies the maximum request per interval, and interval length for a rate limiting rule.