Documentation
¶
Index ¶
- Constants
- Variables
- func GetClientAddr(req *http.Request) net.IP
- func GetHost(req *http.Request) string
- func GetProtocol(req *http.Request) string
- func PasteAddFromForm(req *http.Request, db storage.DB, rateSys *RateLimitSystem, titleMaxLen int, ...) (string, int64, int64, error)
- type ErrTooManyRequests
- type RateLimit
- type RateLimitSystem
Constants ¶
View Source
const (
MaxLengthAuthorAll = 100 // Max length or paste author name, email and URL.
)
Variables ¶
View Source
var ( ErrBadRequest = errors.New("Bad Request") // 400 ErrNotFound = errors.New("Not Found") // 404 ErrMethodNotAllowed = errors.New("Method Not Allowed") // 405 ErrPayloadTooLarge = errors.New("Payload Too Large") // 413 // ErrTooManyRequests = errors.New("Too Many Requests") // 429 ErrInternal = errors.New("Internal Server Error") // 500 )
Functions ¶
func GetProtocol ¶
Types ¶
type ErrTooManyRequests ¶
type ErrTooManyRequests struct { RetryAfter int64 // contains filtered or unexported fields }
func ErrTooManyRequestsNew ¶
func ErrTooManyRequestsNew(retryAfter int64) *ErrTooManyRequests
func (*ErrTooManyRequests) Error ¶
func (e *ErrTooManyRequests) Error() string
type RateLimit ¶
func NewRateLimit ¶
type RateLimitSystem ¶
type RateLimitSystem struct {
// contains filtered or unexported fields
}
func NewRateLimitSystem ¶
func NewRateLimitSystem(per5Min, per15Min, per1Hour uint) *RateLimitSystem
func (*RateLimitSystem) CheckAndUse ¶
func (rateSys *RateLimitSystem) CheckAndUse(ip net.IP) error
Click to show internal directories.
Click to hide internal directories.