package web import ( "log" "net/http" "github.com/gin-gonic/gin" "code.osinet.fr/fgm/sqs_demo/services/redriver" ) func makeHomeHandler(rd redriver.Redriver) gin.HandlerFunc { return func(c *gin.Context) { ctx := c.Request.Context() qURLs, err := rd.ListQueues(ctx, "test") if err != nil { log.Printf("failed listing queues: %v", err) c.JSON(http.StatusInternalServerError, nil) return } qMap := map[string]string{} for _, qURL := range qURLs { name, err := redriver.NameFromURL(qURL) if err != nil { log.Println(http.StatusInternalServerError) c.JSON(http.StatusInternalServerError, nil) } dlqURL, err := rd.GetDLQ(ctx, name) if err != nil { log.Println(err) c.JSON(http.StatusInternalServerError, nil) } qMap[qURL] = dlqURL } c.JSON(http.StatusOK, qMap) } }