package web import ( "log" "net/http" "github.com/gin-gonic/gin" "code.osinet.fr/fgm/sqs_demo/services/redriver" ) func makeQueueHandler(rd redriver.Redriver) gin.HandlerFunc { return func(c *gin.Context) { ctx := c.Request.Context() qName := c.Param("name") qi, err := rd.GetQueueInfo(ctx, qName) if err != nil { log.Printf("failed getting info for queue %q: %v", qName, err) c.JSON(http.StatusInternalServerError, nil) return } items, err := rd.GetQueueItems(ctx, qName) if err != nil { log.Printf("failed getting items for queue %q: %v", qName, err) c.JSON(http.StatusInternalServerError, nil) return } c.JSON(http.StatusOK, map[string]any{"info": qi, "items": items}) } }