middleware.go 574 B

123456789101112131415161718192021222324
  1. package fiber
  2. import (
  3. "github.com/gofiber/fiber/v2"
  4. "github.com/gofiber/fiber/v2/middleware/cors"
  5. "github.com/gofiber/fiber/v2/middleware/recover"
  6. "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/middleware/language"
  7. )
  8. func initMiddleware(app *fiber.App, sp ServiceProvider) {
  9. app.Use(cors.New(getCORSConfig(sp)))
  10. app.Use(recover.New())
  11. app.Use(language.New())
  12. }
  13. func getCORSConfig(sp ServiceProvider) cors.Config {
  14. return cors.Config{
  15. AllowOrigins: sp.ConfigService().CORSAllowOrigins(),
  16. AllowMethods: sp.ConfigService().CORSAllowMethods(),
  17. }
  18. }