28 lines
617 B
Go
28 lines
617 B
Go
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/articles"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
func (h *Handler) ArticlesList(c echo.Context) error {
|
|
userToken, err := c.Cookie(domain.CookieToken)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
resp, err := h.api.Articles.List(userToken.Value, 0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
vm := models.ListArticlesViewModel {
|
|
Items: resp.Payload,
|
|
}
|
|
|
|
return Render(c, http.StatusOK, articles.List(vm))
|
|
} |