Add list all feeds

This commit is contained in:
2024-05-04 18:41:47 +02:00
parent 4f1a4c41e5
commit 31077f9fb5
7 changed files with 74 additions and 23 deletions
+10 -1
View File
@@ -12,6 +12,14 @@ type AddFeedDto struct {
Tags []string `json:"tags" validate:"required"`
}
func (h *Handler) GetFeeds(c echo.Context) error {
ret, err := h.feeds.ListFeeds()
if err != nil {
return err
}
return c.JSON(200, ret)
}
func (h *Handler) AddFeed(c echo.Context) error {
user, err := GetCurrentUserId(c)
if err != nil {
@@ -35,6 +43,7 @@ func (h *Handler) AddFeed(c echo.Context) error {
return c.JSON(201, feed)
}
func (h *Handler) RegisterFeedsRoutes(echo *echo.Echo, r *echo.Group) {
func (h *Handler) RegisterFeedsRoutes(e *echo.Echo, r *echo.Group) {
e.GET("/feeds", h.GetFeeds)
r.POST("/feeds", h.AddFeed)
}
+1 -11
View File
@@ -20,12 +20,6 @@ type RegisterDto struct {
Password string `json:"password" validate:"required"`
}
type UserDto struct {
Id uuid.UUID `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
}
func (h *Handler) Login(c echo.Context) error {
var req LoginDto
err := c.Bind(&req)
@@ -86,11 +80,7 @@ func (h *Handler) GetMe(c echo.Context) error {
if user == nil {
return echo.NewHTTPError(500, "Internal server error")
}
return c.JSON(200, UserDto{
Id: user.Id,
Name: user.Name,
Email: user.Email,
})
return c.JSON(200, user)
}
func GetCurrentUserId(c echo.Context) (uuid.UUID, error) {