Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
type Handler ¶
type Handler struct { Service Service // contains filtered or unexported fields }
func NewHandler ¶
func (*Handler) AddPost ¶
AddPost godoc @Summary Add a new post @Description Add a new post with the input payload @Tags posts @Accept json @Produce json @Param post body postData true "Post Data" @Success 200 {object} models.Post @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /posts [post]
func (*Handler) DeletePost ¶
DeletePost godoc @Summary Delete a post by ID @Description Delete a single post by its ID @Tags posts @Accept json @Produce json @Param id path int true "Post ID" @Success 204 @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /posts/{id} [delete]
func (*Handler) GetAllPosts ¶
GetAllPosts godoc @Summary Get all posts @Description Get a list of all posts @Tags posts @Accept json @Produce json @Success 200 {array} models.Post @Failure 500 {object} ErrorResponse @Router /posts [get]
func (*Handler) GetPost ¶
GetPost godoc @Summary Get a post by ID @Description Get a single post by its ID @Tags posts @Accept json @Produce json @Param id path int true "Post ID" @Success 200 {object} models.Post @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /posts/{id} [get]
func (*Handler) UpdatePost ¶
UpdatePost godoc @Summary Update a post @Description Update a post with the given id @Tags posts @Accept json @Produce json @Param id path int true "Post ID" @Param post body postData true "Post Data" @Success 200 {object} models.Post @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /posts/{id} [put]