Documentation
¶
Index ¶
- Constants
- func MustServe(config Config, factory RouteFactory, mws ...middlewares.Middleware)
- func MustServeFromViper(factory RouteFactory, middlewares ...middlewares.Middleware)
- func ResponseCsv(c *gin.Context, filename string, content [][]string)
- func ResponseError(c *gin.Context, err error)
- func ResponseSuccess(c *gin.Context, data interface{})
- func Wrap(controller func(c *gin.Context) (interface{}, error)) gin.HandlerFunc
- type BusinessError
- type Config
- type RouteFactory
Constants ¶
View Source
const ( ErrCodeSuccess = 0 ErrCodeValidation = 1 ErrCodeInternal = 2 ErrCodeTooManyRequests = 3 )
Variables ¶
This section is empty.
Functions ¶
func MustServe ¶
func MustServe(config Config, factory RouteFactory, mws ...middlewares.Middleware)
func MustServeFromViper ¶
func MustServeFromViper(factory RouteFactory, middlewares ...middlewares.Middleware)
func ResponseError ¶
func ResponseSuccess ¶
Types ¶
type BusinessError ¶
type BusinessError struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` }
func ErrInternal ¶
func ErrInternal(err error) *BusinessError
func ErrTooManyRequests ¶
func ErrTooManyRequests(err error) *BusinessError
func ErrValidation ¶
func ErrValidation(err error) *BusinessError
func NewBusinessError ¶
func NewBusinessError(code int, message string, data interface{}) *BusinessError
func Success ¶
func Success(data interface{}) *BusinessError
func (*BusinessError) Error ¶
func (err *BusinessError) Error() string
type RouteFactory ¶
Click to show internal directories.
Click to hide internal directories.