Changed routing framework from mux to Gin.
Swagger doc is now included in the application. A fronted can now be hosted from the application.
This commit is contained in:
16
pkg/helpers/error.go
Normal file
16
pkg/helpers/error.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package helpers
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func NewError(ctx *gin.Context, status int, err error) {
|
||||
er := HTTPError{
|
||||
Code: status,
|
||||
Message: err.Error(),
|
||||
}
|
||||
ctx.JSON(status, er)
|
||||
}
|
||||
|
||||
type HTTPError struct {
|
||||
Code int `json:"code" example:"400"`
|
||||
Message string `json:"message" example:"status bad request"`
|
||||
}
|
||||
Reference in New Issue
Block a user