package main import ( "os" "time" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/logger" ) const ( MethodList = "LIST" ) var ( fiberConfig = fiber.Config{ AppName: userAgent, ServerHeader: userAgent, StrictRouting: true, DisableDefaultDate: true, DisablePreParseMultipartForm: true, ErrorHandler: fiberErrorHandler, } ) func initFiber() *fiber.App { // adjust with Hashicorp Vault HTTP API haveListMethod := false for _, m := range fiber.DefaultMethods { if m == MethodList { haveListMethod = true break } } if !haveListMethod { fiberConfig.RequestMethods = append(fiber.DefaultMethods, MethodList) } _, debug := os.LookupEnv("DEBUG") if debug { fiberConfig.EnablePrintRoutes = true } app := fiber.New(fiberConfig) app.Use(logger.New(logger.Config{ TimeInterval: 100 * time.Millisecond, })) return app } func fiberOk(c *fiber.Ctx) error { c.Status(fiber.StatusOK) return nil } func fiberNone(c *fiber.Ctx) error { c.Status(fiber.StatusNoContent) return nil } func fiberErrorHandler(c *fiber.Ctx, err error) error { return fiberNone(c) }