51 lines
867 B
Go
51 lines
867 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"math/rand"
|
||
|
"time"
|
||
|
|
||
|
"github.com/gofiber/fiber/v2"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
fiberConfig = fiber.Config{
|
||
|
AppName: userAgent,
|
||
|
ServerHeader: serverAgent,
|
||
|
|
||
|
StrictRouting: true,
|
||
|
CaseSensitive: true,
|
||
|
Immutable: true,
|
||
|
|
||
|
BodyLimit: -1,
|
||
|
ReadTimeout: 10 * time.Millisecond,
|
||
|
|
||
|
DisableKeepalive: true,
|
||
|
DisableHeaderNormalizing: true,
|
||
|
DisablePreParseMultipartForm: true,
|
||
|
DisableDefaultDate: true,
|
||
|
DisableDefaultContentType: true,
|
||
|
|
||
|
ErrorHandler: fiberErrorHandler,
|
||
|
}
|
||
|
)
|
||
|
|
||
|
func initFiberApp() *fiber.App {
|
||
|
preinitFiberConfig()
|
||
|
|
||
|
app := fiber.New(fiberConfig)
|
||
|
preinitFiberApp(app)
|
||
|
app.Use(fiberRngPot)
|
||
|
|
||
|
return app
|
||
|
}
|
||
|
|
||
|
func fiberRngPot(c *fiber.Ctx) error {
|
||
|
return c.SendStatus(
|
||
|
rngRetCodes[rand.Intn(n_rngRetCodes)],
|
||
|
)
|
||
|
}
|
||
|
|
||
|
func fiberErrorHandler(c *fiber.Ctx, err error) error {
|
||
|
return fiberRngPot(c)
|
||
|
}
|