Add blueprint for link update endpoint
This commit is contained in:
parent
c704005ed2
commit
ac066be702
1 changed files with 26 additions and 5 deletions
|
|
@ -82,6 +82,22 @@ func allRetrievalHandler(c echo.Context, serv *PgService) error {
|
|||
return c.JSON(http.StatusOK, models)
|
||||
}
|
||||
|
||||
/*func updateHandler(c echo.Context, serv *PgService) error {
|
||||
linkId := c.Param("id")
|
||||
|
||||
var model UpdateModel
|
||||
if err := json.NewDecoder(c.Request().Body).Decode(&model); err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Invalid data format.")
|
||||
}
|
||||
|
||||
l, err := serv.GetById(linkId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.NoContent(http.StatusOK)
|
||||
}*/
|
||||
|
||||
func removalHandler(c echo.Context, serv *PgService) error {
|
||||
linkId := c.Param("id")
|
||||
|
||||
|
|
@ -95,21 +111,26 @@ func removalHandler(c echo.Context, serv *PgService) error {
|
|||
func AddHandlers(s *echo.Echo, pool *pgxpool.Pool) {
|
||||
serv := NewPgService(PgRepository{pool: pool})
|
||||
|
||||
gr := s.Group("/links")
|
||||
linksGroup := s.Group("/links")
|
||||
exactLinkGroup := linksGroup.Group("/:id")
|
||||
|
||||
gr.POST("", func(ctx echo.Context) error {
|
||||
linksGroup.POST("", func(ctx echo.Context) error {
|
||||
return creationHandler(ctx, &serv)
|
||||
})
|
||||
|
||||
gr.GET("", func(ctx echo.Context) error {
|
||||
linksGroup.GET("", func(ctx echo.Context) error {
|
||||
return allRetrievalHandler(ctx, &serv)
|
||||
})
|
||||
|
||||
gr.GET("/:id", func(ctx echo.Context) error {
|
||||
exactLinkGroup.GET("", func(ctx echo.Context) error {
|
||||
return retrievalByIdHandler(ctx, &serv)
|
||||
})
|
||||
|
||||
gr.DELETE("/:id", func(ctx echo.Context) error {
|
||||
/*exactLinkGroup.PATCH("", func(ctx echo.Context) error {
|
||||
return updateHandler(ctx, &serv)
|
||||
})*/
|
||||
|
||||
exactLinkGroup.DELETE("", func(ctx echo.Context) error {
|
||||
return removalHandler(ctx, &serv)
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue