queue.go 491 B

123456789101112131415161718192021222324
  1. package web
  2. import (
  3. "log"
  4. "net/http"
  5. "github.com/gin-gonic/gin"
  6. "code.osinet.fr/fgm/sqs_demo/services/redriver"
  7. )
  8. func makeQueueHandler(rd redriver.Redriver) gin.HandlerFunc {
  9. return func(c *gin.Context) {
  10. ctx := c.Request.Context()
  11. qName := c.Param("name")
  12. qi, err := rd.GetQueueInfo(ctx, qName)
  13. if err != nil {
  14. log.Printf("failed getting info for queue %q: %v", qName, err)
  15. c.JSON(http.StatusInternalServerError, nil)
  16. return
  17. }
  18. c.JSON(http.StatusOK, qi)
  19. }
  20. }