feat: update docs models responses
This commit is contained in:
27
backend/internal/models/responses.go
Normal file
27
backend/internal/models/responses.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type SuccessResponse struct {
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
type ErrorResponse struct {
|
||||
Error ErrorDetail `json:"error"`
|
||||
}
|
||||
|
||||
type ErrorDetail struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Detail string `json:"detail"`
|
||||
}
|
||||
|
||||
func Success(c *gin.Context, data interface{}) {
|
||||
c.JSON(200, SuccessResponse{Data: data})
|
||||
}
|
||||
|
||||
func Error(c *gin.Context, code int, message string, detail string) {
|
||||
c.JSON(code, ErrorResponse{Error: ErrorDetail{Code: code, Message: message, Detail: detail}})
|
||||
}
|
||||
Reference in New Issue
Block a user