Skip to content

Commit 4e5c7f0

Browse files
committed
Fix response
1 parent 55c6ecf commit 4e5c7f0

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

api/pkg/handlers/handler.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ func (h *handler) responseNotFound(c *fiber.Ctx, message string) error {
5757
})
5858
}
5959

60+
func (h *handler) responseNoContent(c *fiber.Ctx, message string) error {
61+
return c.Status(fiber.StatusNoContent).JSON(fiber.Map{
62+
"status": "success",
63+
"message": message,
64+
})
65+
}
66+
6067
func (h *handler) responseOK(c *fiber.Ctx, message string, data interface{}) error {
6168
return c.Status(fiber.StatusOK).JSON(fiber.Map{
6269
"status": "success",

api/pkg/handlers/phone_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (h *PhoneHandler) Upsert(c *fiber.Ctx) error {
140140
// @Accept json
141141
// @Produce json
142142
// @Param phoneID path string true "ID of the phone" default(32343a19-da5e-4b1b-a767-3298a73703ca)
143-
// @Success 204 {object}
143+
// @Success 204 {object} responses.NoContent
144144
// @Failure 400 {object} responses.BadRequest
145145
// @Failure 401 {object} responses.Unauthorized
146146
// @Failure 422 {object} responses.UnprocessableEntity

api/pkg/responses/response.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ type Unauthorized struct {
3737
Message string `json:"message" example:"You are not authorized to carry out this request."`
3838
Data string `json:"data" example:"Make sure your API key is set in the [X-API-Key] header in the request"`
3939
}
40+
41+
// NoContent is the response when status code is 204
42+
type NoContent struct {
43+
Status string `json:"status" example:"success"`
44+
Message string `json:"message" example:"phone deleted successfully"`
45+
}

0 commit comments

Comments
 (0)