routes.go 645 B

12345678910111213141516171819202122232425262728
  1. package web
  2. import (
  3. _ "embed"
  4. "github.com/fgm/izidic"
  5. "github.com/gin-gonic/gin"
  6. "code.osinet.fr/fgm/sqs_demo/services"
  7. "code.osinet.fr/fgm/sqs_demo/services/redriver"
  8. )
  9. //go:embed public/redriver.css
  10. var css []byte
  11. func SetupRoutes(rd redriver.Redriver) *gin.Engine {
  12. r := gin.Default()
  13. r.SetTrustedProxies(nil)
  14. r.GET("/", makeHomeHandler(rd))
  15. r.GET("/public/redriver.css", func(c *gin.Context) { c.Writer.Write(css) })
  16. r.GET("/queue/:name", makeQueueHandler(rd))
  17. return r
  18. }
  19. func HttpService(dic *izidic.Container) (any, error) {
  20. rd := dic.MustService(services.SvcRedriver).(redriver.Redriver)
  21. return SetupRoutes(rd), nil
  22. }