package handlers import ( "net/http" "git.jamestombleson.com/jtom38/newsbot-portal/internal/domain" "git.jamestombleson.com/jtom38/newsbot-portal/internal/models" "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/layout" "git.jamestombleson.com/jtom38/newsbot-portal/internal/views/sources" "github.com/labstack/echo/v4" ) func (h *Handler) ListAllSources(c echo.Context) error { _, err := ValidateJwt(c, h.config.JwtSecret, h.config.ServerAddress) if err != nil { return Render(c, http.StatusOK, layout.Error(err)) } userToken, err := c.Cookie(domain.CookieToken) if err != nil { return Render(c, http.StatusBadRequest, layout.Error(err)) } resp, err := h.api.Sources.ListAll(userToken.Value, 0) if err != nil { return Render(c, http.StatusOK, layout.Error(err)) } return Render(c, http.StatusOK, sources.ListAll(models.ListAllSourcesViewModel{ Items: resp.Payload, IsError: resp.IsError, Message: resp.Message, })) }