mirror of
https://github.com/zoriya/vex.git
synced 2026-06-04 11:04:34 +00:00
Add list all feeds
This commit is contained in:
+10
-1
@@ -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
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user