Documentation ¶
Index ¶
- Variables
- func End(w http.ResponseWriter, code int)
- func JSON(w http.ResponseWriter, code int, data interface{})
- type Cause
- type Data
- type Err
- func Bind(src io.ReadCloser, dst interface{}) *Err
- func NewBadRequestErr(message string, causes []Cause) *Err
- func NewErr(message, err string, code int, causes []Cause) *Err
- func NewForbiddenErr(message string) *Err
- func NewInternalServerErr(message string) *Err
- func NewNotFoundErr(message string) *Err
- func NewUnauthorizedErr() *Err
- func ValidateStructErr(err error) *Err
- func ValidateVarErr(name string, err error) *Err
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Validate = validator.New()
)
Functions ¶
func JSON ¶
func JSON(w http.ResponseWriter, code int, data interface{})
Write http status code and return data in JSON format
Types ¶
type Data ¶ added in v1.0.4
type Data map[string]interface{}
Data is one shortcut to map[string]interface{}
type Err ¶
type Err struct { Message string `json:"message"` Code int `json:"code"` Err string `json:"error"` Causes []Cause `json:"causes,omitempty"` }
Default rest error type.
func Bind ¶
func Bind(src io.ReadCloser, dst interface{}) *Err
Bind the src JSON request to dst struct. Returns a rest.Err if an error occurs in the binding process
func NewBadRequestErr ¶
Creates a new Bad Request Error.
func NewInternalServerErr ¶
Creates a new Internal Server Error.
func ValidateStructErr ¶
Validate one struct error. Returns rest.Err with the cause of the error occurrence.
func ValidateVarErr ¶
Validate one variable error. Returns rest.Err with the cause of the error occurrence.
Click to show internal directories.
Click to hide internal directories.