rate-limit: github.com/ahmdrz/rate-limit Index | Files | Directories

package ratelimit

import "github.com/ahmdrz/rate-limit"

Index

Package Files

ratelimit.go types.go whitelist.go

Variables

var DefaultHandler = func(w http.ResponseWriter, r *http.Request) {
    w.WriteHeader(429)
}

type HandlerLimiter Uses

type HandlerLimiter struct {
    RateLimiter
    http.Handler
}

func NewHandler Uses

func NewHandler(handler http.Handler, requests int, limitTime time.Duration, blockedHandler http.HandlerFunc) *HandlerLimiter

func (*HandlerLimiter) ServeHTTP Uses

func (h *HandlerLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request)

type List Uses

type List map[string]bool
var WhiteList List = make(List)

func (List) Add Uses

func (l List) Add(uri string)

func (List) HasPrefix Uses

func (l List) HasPrefix(uri string)

func (List) Remove Uses

func (l List) Remove(uri string)

type RateLimiter Uses

type RateLimiter struct {
    IsUsingProxy  bool
    ValidateByURI bool
    // contains filtered or unexported fields
}

func InitRateLimit Uses

func InitRateLimit(requests int, limitTime time.Duration, blockedHandler http.HandlerFunc) *RateLimiter

func (*RateLimiter) RateLimit Uses

func (rl *RateLimiter) RateLimit(h http.HandlerFunc) http.HandlerFunc

type Request Uses

type Request struct {
    Time  int64
    Count int
}

Directories

PathSynopsis
example

Package ratelimit imports 4 packages (graph) and is imported by 1 packages. Updated 2017-02-25. Refresh now. Tools for package owners.