Documentation ¶
Index ¶
- Constants
- Variables
- func Err(statusCode int) (e error)
- func Get(statusCode int) (int, error)
- func GetStatusMsg(statusCode int) (s string)
- func New(retStatusMap map[int]GroupRetStatusCode) error
- func Override(retStatusMap map[int]GroupRetStatusCode)
- type BaseRequest
- type BaseResponse
- type GroupRetStatusCode
- type RetStatus
- func (retStatus *RetStatus) Err() (e error)
- func (r RetStatus) Error() string
- func (retStatus *RetStatus) Is(retStatusCode int) bool
- func (retStatus *RetStatus) IsSuccess() bool
- func (r RetStatus) MarshalJSON() ([]byte, error)
- func (retStatus *RetStatus) SetSuccess()
- func (retStatus *RetStatus) Update(statusCode int)
Constants ¶
View Source
const ( Mysql = 3300 // Mysql基礎號段 Mysql_InvalidInput = 3301 // 無效參數 Mysql_ResourceNotFound = 3302 // 資源不存在 Mysql_Unknown = 3303 // 未知錯誤 Mysql_InternalServiceError = 3304 // 內部服務錯誤 Mysql_ExternalServiceError = 3305 // 外部服務錯誤 )
View Source
const Success = 10000 // Success : 正常返回
View Source
const UnknownStatusCode = "Unknown Status Code"
UnknownStatusCode : 未知代碼(可能未宣告const或map)
Variables ¶
View Source
var ErrKeyConflict = errors.New("key conflict")
ErrKeyConflict : retStatusCode衝突
View Source
var ErrKeyOutOfRange = errors.New("key out of range")
ErrKeyOutOfRange : retStatusCode 超出可自訂範圍(自訂範圍為6位數)
Functions ¶
func GetStatusMsg ¶
GetStatusMsg : 將 statusCode 轉為 error msg
Types ¶
type BaseRequest ¶
type BaseResponse ¶
type BaseResponse struct {
RetStatus RetStatus `json:"retStatus"`
}
BaseResponse : 基礎回應資料結構
func (BaseResponse) Error ¶
func (b BaseResponse) Error() string
type GroupRetStatusCode ¶
type RetStatus ¶
type RetStatus struct { StatusCode int `json:"StatusCode" qs:"StatusCode"` StatusMsg string `json:"StatusMsg" qs:"StatusMsg"` SystemTime int64 `json:"SystemTime" qs:"SystemTime"` CheckCode int `json:"CheckCode" qs:"CheckCode"` }
func CreateSuccess ¶
func CreateSuccess() (retStatus *RetStatus)
CreateSuccess : 建立一個 Success 的 RetStatus
func (RetStatus) MarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.