Documentation ¶
Index ¶
Constants ¶
View Source
const ( MaxBodyLimit = 30 << 20 // 30MB MaxReqProcsPerSeconds = 30 MaxReqGuestTokenPerSeconds = 3 )
Variables ¶
View Source
var Cache = cache.New(cache.Config{ Expiration: 10 * time.Second, CacheControl: true, })
View Source
var Cors = cors.New(cors.Config{ AllowMethods: strings.Join(auth.AllowedHttpMethod, ","), AllowHeaders: strings.Join([]string{fiber.HeaderContentType, fiber.HeaderContentLength, fiber.HeaderAccept, fiber.HeaderUserAgent, fiber.HeaderAcceptEncoding, fiber.HeaderAcceptCharset, fiber.HeaderAuthorization, fiber.HeaderOrigin, fiber.HeaderLocation, fiber.HeaderKeepAlive}, ","), })
View Source
var RateLimiterGuestToken = limiter.New(limiter.Config{ Max: MaxReqGuestTokenPerSeconds, KeyGenerator: func(ctx *fiber.Ctx) string { var ( realIp = ctx.Get(auth.HeaderRealIp) xRealIp = ctx.Get(auth.HeaderXRealIp) ) if realIp != "" { return utils.CopyString(realIp) } if xRealIp != "" { return utils.CopyString(xRealIp) } return ctx.IP() }, LimitReached: func(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusTooManyRequests).JSON(&models.ApiError{ Error: &models.Error{ Kind: "too_many_request_token", Description: fmt.Sprintf("Maximum Request Exceeded, Maximum %d Request per seconds for guest token", MaxReqGuestTokenPerSeconds), }, }) }, })
View Source
var RateLimiterProcessing = limiter.New(limiter.Config{ KeyGenerator: func(ctx *fiber.Ctx) string { return utils.CopyString(ctx.Get(fiber.HeaderAuthorization)) }, Max: MaxReqProcsPerSeconds, LimitReached: func(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusTooManyRequests).JSON(&models.ApiError{ Error: &models.Error{ Kind: "too_many_request", Description: fmt.Sprintf("Maximum Request Exceeded, Maximum %d Request per seconds for user", MaxReqProcsPerSeconds), }, }) }, })
Functions ¶
func AutoDeleteScheduler ¶
func AutoDeleteScheduler(ctx *fiber.Ctx) error
func CatchServerError ¶
func CheckHttpMethod ¶
func CheckHttpMethod(ctx *fiber.Ctx) error
func PurgeAnonymousAccount ¶
func PurgeAnonymousAccount(ctx *fiber.Ctx) error
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.