Versions in this module Expand all Collapse all v1 v1.0.0 Aug 16, 2017 Changes in this version + const DefaultCleanUpInterval + const DefaultMaxRetry + const DefaultPrefix + func GetIP(r *http.Request) net.IP + func GetIPKey(r *http.Request) string + func Random(min, max int) int + type Context struct + Limit int64 + Reached bool + Remaining int64 + Reset int64 + type GJRMiddleware struct + Limiter *Limiter + func NewGJRMiddleware(limiter *Limiter) *GJRMiddleware + func (m *GJRMiddleware) MiddlewareFunc(h rest.HandlerFunc) rest.HandlerFunc + type HTTPMiddleware struct + Limiter *Limiter + func NewHTTPMiddleware(limiter *Limiter) *HTTPMiddleware + func (m *HTTPMiddleware) Handler(h http.Handler) http.Handler + type Limiter struct + Rate Rate + Store Store + func NewLimiter(store Store, rate Rate) *Limiter + func (l *Limiter) Get(key string) (Context, error) + func (l *Limiter) Peek(key string) (Context, error) + type MemoryStore struct + Cache *cache.Cache + Prefix string + func (s *MemoryStore) Get(key string, rate Rate) (Context, error) + func (s *MemoryStore) Peek(key string, rate Rate) (Context, error) + type Rate struct + Formatted string + Limit int64 + Period time.Duration + func NewRateFromFormatted(formatted string) (Rate, error) + type RedisStore struct + MaxRetry int + Pool *redis.Pool + Prefix string + func (s RedisStore) Get(key string, rate Rate) (Context, error) + func (s RedisStore) Peek(key string, rate Rate) (Context, error) + type RedisStoreFunc func(c redis.Conn, key string, rate Rate) ([]int, error) + type Store interface + Get func(key string, rate Rate) (Context, error) + Peek func(key string, rate Rate) (Context, error) + func NewMemoryStore() Store + func NewMemoryStoreWithOptions(options StoreOptions) Store + func NewRedisStore(pool *redis.Pool) (Store, error) + func NewRedisStoreWithOptions(pool *redis.Pool, options StoreOptions) (Store, error) + type StoreOptions struct + CleanUpInterval time.Duration + MaxRetry int + Prefix string Incompatible versions in this module v2.2.0+incompatible Mar 5, 2018 v2.1.0+incompatible Nov 10, 2017 v2.0.0+incompatible Oct 10, 2017