Documentation
¶
Index ¶
- Constants
- Variables
- type Enpoints
- type InternalRateLimitClient
- type InternalRateStore
- func (s *InternalRateStore) Get(route interface{}, endpointName string, methodName string) (*Rate, error)
- func (s *InternalRateStore) GetAppRate(route interface{}) (*Rate, error)
- func (s *InternalRateStore) IsRateLimited(rate *Rate) (bool, error)
- func (s *InternalRateStore) Set(route interface{}, endpointName string, methodName string, ...) error
- func (s *InternalRateStore) SetAppRate(route interface{}, headers *http.Header) error
- func (s *InternalRateStore) UpdateInternalRateCount(old *Rate, new *Rate)
- type Methods
- type Rate
- type RateLimit
- func (r *RateLimit) Get(route interface{}, endpointName string, methodName string) (*Rate, error)
- func (r *RateLimit) GetAppRate(route interface{}) (*Rate, error)
- func (r *RateLimit) IsRateLimited(rate *Rate) (bool, error)
- func (r *RateLimit) Set(route interface{}, endpointName string, methodName string, ...) error
- func (r *RateLimit) SetAppRate(route interface{}, headers *http.Header) error
- type RateLimitStoreType
- type RateTiming
- type Store
Constants ¶
View Source
const ( AppRateLimitHeader = "X-App-Rate-Limit" AppRateLimitCountHeader = "X-App-Rate-Limit-Count" MethodRateLimitHeader = "X-Method-Rate-Limit" MethodRateLimitCountHeader = "X-Method-Rate-Limit-Count" )
Variables ¶
View Source
var (
ErrRateLimitingIsDisabled = errors.New("Rate limiting is disabled")
)
Functions ¶
This section is empty.
Types ¶
type InternalRateLimitClient ¶
type InternalRateLimitClient interface {
Get(route interface{}, endpointName string, methodName string) (*Rate, error)
GetAppRate(route interface{}) (*Rate, error)
Set(route interface{}, endpointName string, methodName string, headers *http.Header) error
SetAppRate(route interface{}, headers *http.Header) error
ParseHeaders(headers *http.Header, limitHeader string, countHeader string) (*Rate, error)
IsRateLimited(rate *Rate) (bool, error)
}
type InternalRateStore ¶
type InternalRateStore struct {
Route map[interface{}]*Enpoints
// contains filtered or unexported fields
}
func (*InternalRateStore) Get ¶
func (s *InternalRateStore) Get(route interface{}, endpointName string, methodName string) (*Rate, error)
func (*InternalRateStore) GetAppRate ¶
func (s *InternalRateStore) GetAppRate(route interface{}) (*Rate, error)
func (*InternalRateStore) IsRateLimited ¶
func (s *InternalRateStore) IsRateLimited(rate *Rate) (bool, error)
func (*InternalRateStore) SetAppRate ¶
func (s *InternalRateStore) SetAppRate(route interface{}, headers *http.Header) error
func (*InternalRateStore) UpdateInternalRateCount ¶
func (s *InternalRateStore) UpdateInternalRateCount(old *Rate, new *Rate)
type Rate ¶
type Rate struct {
Seconds RateTiming
Minutes RateTiming
}
type RateLimit ¶
type RateLimit struct {
Enabled bool
StoreType RateLimitStoreType
// contains filtered or unexported fields
}
func NewInternalRateLimit ¶
func (*RateLimit) GetAppRate ¶
type RateLimitStoreType ¶
type RateLimitStoreType string
const (
InternalRateLimiter RateLimitStoreType = "Internal"
)
type RateTiming ¶
type Store ¶
type Store interface {
Get(route interface{}, endpointName string, methodName string) (*Rate, error)
GetAppRate(route interface{}) (*Rate, error)
Set(route interface{}, endpointName string, methodName string, headers *http.Header) error
SetAppRate(route interface{}, headers *http.Header) error
IsRateLimited(rate *Rate) (bool, error)
}
Click to show internal directories.
Click to hide internal directories.