Documentation
¶
Index ¶
Constants ¶
View Source
const StatusAny = 0
StatusAny stand for any status when block.
View Source
const StatusAnyError = -1
StatusAnyError stand for any status greater than 400 when block.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Blocker ¶
type Blocker struct { //Cache cache which store blcok data Cache cache.Cacheable //StatusCodeBlocked error status which will returned when request blcoker.Default value is 429. StatusCodeBlocked int //Identifier http request identifier Identifier func(r *http.Request) (string, error) //OnBlock acitons execed when access blocked OnBlock func(w http.ResponseWriter, r *http.Request) // contains filtered or unexported fields }
Blocker blocker struct.
func (*Blocker) Block ¶
Block block config method. Requester request for morethan param max request which response staus is param status in param ttl will be blocked.
func (*Blocker) DefaultBlockAction ¶
func (b *Blocker) DefaultBlockAction(w http.ResponseWriter, r *http.Request)
DefaultBlockAction default block
func (*Blocker) ServeMiddleware ¶
func (b *Blocker) ServeMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeMiddleware serve blocker as a middleware.
Click to show internal directories.
Click to hide internal directories.