Documentation ¶
Index ¶
- 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 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. If found, use an existing X-Forwarded-For IP included by a load-balancer in the infrastructure. 2. If 1. isn't present, it will use the connection remote address.
Types ¶
type ContextKey ¶
type ContextKey int
ContextKey is used to key context values.
const ( // ContextKeyChainID is used to store the chain id of the client for the incoming request, // this is found in the request path. ContextKeyChainID ContextKey = iota // ContextIPAddress is used to store the ip address of the client for the incoming request, // this is found in either the request IP or the x-forwarded header. ContextIPAddress ContextKey = iota )
type RateLimiterConfig ¶
type RateLimiterConfig struct {
Default RateLimiterRouteConfig
}
RateLimiterConfig specifies a default rate limiting configuration.
Click to show internal directories.
Click to hide internal directories.