Documentation ¶
Index ¶
- Constants
- Variables
- func HandleError(c echo.Context, errcode ErrorNo, errmsg ...string) error
- func HandleSuccess(c echo.Context, i interface{}) error
- func JWT(next echo.HandlerFunc) echo.HandlerFunc
- func MetricsFunc(m *metrics2.Metrics) echo.MiddlewareFunc
- func NewUserClient(srvname string)
- func Opentracing(next echo.HandlerFunc) echo.HandlerFunc
- func RpcErr(c echo.Context, err error) error
- func Run()
- func VerifyParam(next echo.HandlerFunc) echo.HandlerFunc
- type ErrorNo
- type Page
- type ReqParam
- func (r *ReqParam) CompareSign() (bool, error)
- func (r *ReqParam) CreateSign() (string, error)
- func (r *ReqParam) DataDecode(v interface{}) error
- func (r *ReqParam) DataEncode(v interface{}) error
- func (r *ReqParam) Decode(s string) error
- func (r *ReqParam) InitPage(total int64)
- func (r *ReqParam) R(v interface{}) (interface{}, error)
- func (r *ReqParam) Validate() error
Constants ¶
View Source
const ( //成功 Success ErrorNo = 0 //请求 ReqPathError = 10001 ReqVersionNoExist = 10002 ReqInterfaceNoExist = 10003 ReqCommandNoExist = 10004 ReqInterfaceNoSupport = 10005 ReqNoAllow = 10006 //公共 CommonPageError = 20001 //分页错误 CommonParamError = 20002 //参数错误 CommonParamConvertError = 20003 //参数转换错误 CommonSignError = 20004 //签名错误 CommonAppError = 20008 //app错误 //业务参数 BusParamError = 30001 //参数错误 BusParamConvertError = 30002 //参数转换错误 //服务端处理异常 ServiceError = 50001 )
View Source
const SN = "com.example.api.common"
定义services名称
Variables ¶
View Source
var ReturnMsg map[ErrorNo]string = map[ErrorNo]string{ Success: "success", ReqPathError: "请求路径错误", ReqVersionNoExist: "请求版本不存在", ReqInterfaceNoExist: "请求接口不存在", ReqCommandNoExist: "请求命令不存在", ReqInterfaceNoSupport: "接口在当前请求命令中未被支持", ReqNoAllow: "请求不允许", CommonPageError: "分页错误", CommonParamError: "公共参数错误", CommonParamConvertError: "公共参数转换错误", CommonSignError: "公共参数签名错误", CommonAppError: "商户账户不存在或不可用", BusParamError: "业务参数错误", BusParamConvertError: "业务参数转换错误", ServiceError: "服务端处理异常", }
View Source
var (
UserClient user.UserService
)
Functions ¶
func NewUserClient ¶
func NewUserClient(srvname string)
Types ¶
type Page ¶
type Page struct { PageIndex int64 `json:"pageIndex"` //页面索引 PageSize int64 `json:"pageSize"` //每页大小 PageTotal int64 `json:"pageTotal"` //总分页数 Count int64 `json:"count"` //当页记录数 Total int64 `json:"total"` //总记录数 }
分页
type ReqParam ¶
type ReqParam struct { AppId int `json:"-"` //AppID AppKey string `json:"appKey" valid:"required~appKey必须存在"` //密钥ID AppSecret string `json:"appSecret" valid:"-"` //密钥 RequestId string `json:"requestId" valid:"required~required必须存在"` //32位的唯一请求标识,用于问题排查和防止重复提交 Timestamp string `json:"timestamp" valid:"required~毫秒时间戳必须存在"` //毫秒时间戳 Custom string `json:"custom" valid:"-"` //第三方自定义内容 Nonce string `json:"nonce" valid:"required~随机数必须存在,length(8|8)~随机数必须满足8位"` //8 位随机数 Language string `json:"language" valid:"in(cn|en)"` //多语言支持 Sign string `json:"sign" valid:"required~签名必须存在"` //签名 SignType string `json:"signType" valid:"required~签名类型必须存在"` //签名类型:MD5 SHA_1 SHA_256 SHA_512 Encode bool `json:"encode" valid:"-"` //响应数据data是否进行base64编码,默认true Data string `json:"data" valid:"-"` //请求的数据 Remark string `json:"remark"` //APP备注 Page Page `json:"page"` //分页 IsPage bool `json:"isPage"` //是否分页 }
func (*ReqParam) CompareSign ¶
* 根据签名类型比较签名 true:相同 false:不同
func (*ReqParam) DataDecode ¶
* **解析data参数 **input: v point **ouput: error
func (*ReqParam) DataEncode ¶
* **编码data参数 **input: v interface **ouput: error
Click to show internal directories.
Click to hide internal directories.