Documentation ¶
Overview ¶
Package middleware include param, reqlog, response, safe related functional modules
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResponseErrorJson ¶
func ResponseErrorJson(w http.ResponseWriter, je interface{})
ResponseErrorJson response JsonErr data to client
func ResponseJson ¶
func ResponseJson(w http.ResponseWriter, i interface{})
ResponseJson response interface{} as json string to client
func SafeHandler ¶
func SafeHandler(w http.ResponseWriter, req *http.Request)
SafeHandler recover from panic will be used in `Handler.ServeHTTP`
Types ¶
type ParamError ¶
type ParamError struct { Field string `json:"field"` Value interface{} `json:"value"` Message string `json:"message"` }
ParamError include Field, Value, Message
func NewParamError ¶
func NewParamError(field, message string, value interface{}) *ParamError
new ParamError with (field, message string, value interface{})
func NewParamErrorFromValidError ¶
func NewParamErrorFromValidError(ve *valid.Error) *ParamError
new ParamError from valid.Error
func ParseParams ¶
func ParseParams(w http.ResponseWriter, req *http.Request, reqRes interface{}) (errs []*ParamError)
ParseParams, parse params into reqRes from req.Form, and support form-data, json-body TODO: support parse file
func (*ParamError) String ¶
func (pe *ParamError) String() string
String of ParamError, to format as string
Click to show internal directories.
Click to hide internal directories.