Documentation
¶
Index ¶
Constants ¶
View Source
const ( FAILURE = 410 SUCCESS = 200 )
View Source
const ( CLIENT = iota MASTER SLAVER ANALYSE )
Variables ¶
View Source
var ( ErrorUnknow = NewErr(9999, "未知错误") ErrorCustom = NewErr(9000, "") ErrorParseParam = NewErr(400, "参数解析成JSON出错! %v") ErrorKeyParam = NewErr(400, "[%v] %v") ErrorHTTPMethodNotAllowed = NewErr(http.StatusMethodNotAllowed, http.StatusText(http.StatusMethodNotAllowed)) ErrorNotProvideOperation = NewErr(2000, "未提供的操作") )
View Source
var ( GitCommit = "" GitTag = "" BuildDate = "" )
Functions ¶
This section is empty.
Types ¶
type ErrorModel ¶
type ErrorModel struct {
Code int `json:"code"`
Message string `json:"message"`
Suggest string `json:"suggest"`
Params map[string]interface{} `json:"params"`
}
func NewCustomErr ¶
func NewCustomErr(msg string, arg ...interface{}) *ErrorModel
func NewErr ¶
func NewErr(code int, msg string) ErrorModel
func (*ErrorModel) AddParam ¶
func (obj *ErrorModel) AddParam(key string, val interface{})
func (ErrorModel) ToError ¶
func (obj ErrorModel) ToError() error
type RequestModel ¶
type RequestModel struct {
Method string
Url string
Header map[string]interface{}
Body interface{}
}
func NewRequestModel ¶
func NewRequestModel(url string) RequestModel
type ResponseModel ¶
type ResponseModel struct {
Header map[string]interface{}
Status int
Content interface{}
Error ErrorModel
}
type Result ¶
type Result struct {
Code int //当前状态
Header map[string]interface{}
Error *ErrorModel //输出的内容(出错的提示)
Context interface{} //执行后的结果
}
func ErrorResult ¶
func ErrorStrResult ¶
func FailureResult ¶
func FailureResultWithErr ¶ added in v1.0.1
func SuccessResult ¶
func SuccessResult(c interface{}) Result
func (Result) GetContext ¶
func (r Result) GetContext() interface{}
type ResultOperate ¶
Click to show internal directories.
Click to hide internal directories.