Documentation ¶
Index ¶
- func Bind(req *http.Request, data interface{}) error
- func BindForm(req *http.Request, data interface{}) error
- func BindJSON(req *http.Request, data interface{}) error
- func BindURI(req *http.Request, data interface{}) error
- func Convert(h Handler) func(req *http.Request) *Result
- func ErrorRender(err error, w http.ResponseWriter, req *http.Request)
- func JSONDeserializer(req *http.Request, data interface{}) error
- func RawConvert(h Handler) func(req *http.Request) *Result
- func Render(w http.ResponseWriter, req *http.Request, res *Result)
- func ValidateData(data interface{}, lang ut.Translator) error
- type Endpoint
- type Handler
- type RequestInfo
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorRender ¶
func ErrorRender(err error, w http.ResponseWriter, req *http.Request)
func JSONDeserializer ¶
func ValidateData ¶
func ValidateData(data interface{}, lang ut.Translator) error
Types ¶
type Endpoint ¶
type Endpoint struct { Path string Method string Handler func(*http.Request) *Result RegisterHandler func(*mux.Router) *mux.Route Authorizer *iauth.Authorization }
type RequestInfo ¶
type RequestInfo struct { StartTime time.Time Duration time.Duration URLPath string Method string ClientIP string LogID string URLPattern string StatusCode int RetMsg string ErrDetail string }
func GetRequestInfo ¶
func GetRequestInfo(ctx context.Context) *RequestInfo
func InitRequestInfo ¶
func (*RequestInfo) String ¶
func (requestInfo *RequestInfo) String() string
type Result ¶
type Result struct { OriginErr error `json:"-"` Code int `json:"ErrNum"` // http status code ErrMsg string `json:"ErrMsg"` // return message if failed Data interface{} `json:"Data,omitempty"` // return data if success Render func(w http.ResponseWriter, req *http.Request, res *Result) `json:"-"` }
Result used for result process
Click to show internal directories.
Click to hide internal directories.