Documentation
¶
Overview ¶
Package rest provides operations to implement a RESTful API.
Route ¶
A Route provides a easy way to define HTTP routes and handle it.
Rest ¶
A Rest provides an URL router for a RESTful API.
Route ¶
A Route provides a easy way to define HTTP routes and handle it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
CloudflareRanges = []string{
"https://www.cloudflare.com/ips-v4",
"https://www.cloudflare.com/ips-v6",
}
)
Functions ¶
func RecoverHandlerJson ¶
RecoverHandlerJson is a HTTP request middleware that captures panic errors and returns it as HTTP JSON response.
Types ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
A RateLimiter limits the number of requests per timing window.
func NewRateLimiter ¶
func NewRateLimiter(store data.Store, threshold int) *RateLimiter
NewRateLimiter creates a new instance of RateLimiter based on specified store and number of requests per timing window.
func (*RateLimiter) AddCall ¶
func (lmt *RateLimiter) AddCall(id string) int
AddCall register a new request for specified identifier and returns how many levels the identifier overflow the threshold.
func (*RateLimiter) Stack ¶
func (lmt *RateLimiter) Stack(another *RateLimiter)
Stack sets a rate limiter for the next level.