Documentation
¶
Index ¶
- Variables
- func MustServe(endpoint string, factory RouteFactory, option ...RouterOption)
- func Serve(endpoint string, factory RouteFactory, option ...RouterOption) error
- func Wrap(controller func(c *gin.Context) (interface{}, error)) gin.HandlerFunc
- type BusinessError
- type RouteFactory
- type RouterOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNil = NewBusinessError(0, "Success") ErrValidation = NewBusinessError(1, "Invalid parameter") ErrInternal = NewBusinessError(2, "Internal server error") )
General errors
View Source
var ErrHandled = new(BusinessError)
Functions ¶
func MustServe ¶
func MustServe(endpoint string, factory RouteFactory, option ...RouterOption)
func Serve ¶
func Serve(endpoint string, factory RouteFactory, option ...RouterOption) error
Types ¶
type BusinessError ¶
type BusinessError struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` }
func NewBusinessError ¶
func NewBusinessError(code int, message string) *BusinessError
func NewBusinessErrorWithData ¶
func NewBusinessErrorWithData(code int, message string, data interface{}) *BusinessError
func (*BusinessError) Error ¶
func (err *BusinessError) Error() string
func (*BusinessError) WithData ¶
func (be *BusinessError) WithData(data interface{}) *BusinessError
type RouteFactory ¶
type RouterOption ¶
Click to show internal directories.
Click to hide internal directories.