Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/route status created #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@
}
],
"responses": {
"200": {
"description": "OK",
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/handler.CreateOpeningResponse"
}
Expand Down
4 changes: 2 additions & 2 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ paths:
produces:
- application/json
responses:
"200":
description: OK
"201":
description: Created
schema:
$ref: '#/definitions/handler.CreateOpeningResponse'
"400":
Expand Down
4 changes: 2 additions & 2 deletions handler/createOpening.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
// @Accept json
// @Produce json
// @Param request body CreateOpeningRequest true "Request body"
// @Success 200 {object} CreateOpeningResponse
// @Success 201 {object} CreateOpeningResponse
// @Failure 400 {object} ErrorResponse
// @Failure 500 {object} ErrorResponse
// @Router /opening [post]
Expand Down Expand Up @@ -45,5 +45,5 @@ func CreateOpeningHandler(ctx *gin.Context) {
return
}

sendSuccess(ctx, "create-opening", opening)
sendSuccess(ctx, http.StatusCreated, "create-opening", opening)
}
2 changes: 1 addition & 1 deletion handler/deleteOpening.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ func DeleteOpeningHandler(ctx *gin.Context) {
sendError(ctx, http.StatusInternalServerError, fmt.Sprintf("error deleting opening with id: %s", id))
return
}
sendSuccess(ctx, "delete-opening", opening)
sendSuccess(ctx, http.StatusOK, "delete-opening", opening)
}
2 changes: 1 addition & 1 deletion handler/listOpenings.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ func ListOpeningsHandler(ctx *gin.Context) {
return
}

sendSuccess(ctx, "list-openings", openings)
sendSuccess(ctx, http.StatusOK, "list-openings", openings)
}
5 changes: 2 additions & 3 deletions handler/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package handler

import (
"fmt"
"net/http"

"github.com/arthur404dev/gopportunities/schemas"
"github.com/gin-gonic/gin"
Expand All @@ -16,9 +15,9 @@ func sendError(ctx *gin.Context, code int, msg string) {
})
}

func sendSuccess(ctx *gin.Context, op string, data interface{}) {
func sendSuccess(ctx *gin.Context, status int, op string, data interface{}) {
ctx.Header("Content-type", "application/json")
ctx.JSON(http.StatusOK, gin.H{
ctx.JSON(status, gin.H{
"message": fmt.Sprintf("operation from handler: %s successfull", op),
"data": data,
})
Expand Down
2 changes: 1 addition & 1 deletion handler/showOpening.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ func ShowOpeningHandler(ctx *gin.Context) {
return
}

sendSuccess(ctx, "show-opening", opening)
sendSuccess(ctx, http.StatusOK, "show-opening", opening)
}
2 changes: 1 addition & 1 deletion handler/updateOpening.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ func UpdateOpeningHandler(ctx *gin.Context) {
sendError(ctx, http.StatusInternalServerError, "error updating opening")
return
}
sendSuccess(ctx, "update-opening", opening)
sendSuccess(ctx, http.StatusOK, "update-opening", opening)
}