public_handlers.go 822 B

1234567891011121314151617181920212223242526272829303132333435
  1. package fiber
  2. import (
  3. "github.com/gofiber/fiber/v2"
  4. "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/handler"
  5. )
  6. func initPublicHandlers(app *fiber.App, sp ServiceProvider) {
  7. mainPageHandler := handler.MainPageHandler(
  8. sp.CacheService(),
  9. sp.ArticleRepository(),
  10. )
  11. app.Get("/:lang<regex(^en$)>", mainPageHandler)
  12. app.Get("/", mainPageHandler)
  13. tagPageHandler := handler.TagHandler(
  14. sp.CacheService(),
  15. sp.ArticleRepository(),
  16. sp.TagRepository(),
  17. )
  18. app.Get("/:lang<regex(^en$)/tag/:tag>", tagPageHandler)
  19. app.Get("/tag/:tag", tagPageHandler)
  20. articlePageHandler := handler.ArticleHandler(
  21. sp.CacheService(),
  22. sp.ArticleRepository(),
  23. sp.TagRepository(),
  24. )
  25. app.Get("/:lang<regex(^en$)/article/:article", articlePageHandler)
  26. app.Get("/article/:article", articlePageHandler)
  27. }