1
0
rngpotd/fiber.go
Konstantin Demin a9f9014edd
Some checks failed
ci/woodpecker/push/build Pipeline failed
ci/woodpecker/manual/build Pipeline was successful
ci/woodpecker/manual/latest Pipeline failed
initial commit
2024-07-19 16:52:06 +03:00

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)
}