Documentation ¶
Index ¶
- Constants
- func HandleNotFound(c *gin.Context)
- func HandleSQLError(err string) error
- func StatusText(code int) string
- func Wrapper(handler HandlerFunc) func(c *gin.Context)
- type APIException
- func StatusBadGateway(message string) *APIException
- func StatusBadRequest(message string) *APIException
- func StatusConflict(message string) *APIException
- func StatusForbidden(message string) *APIException
- func StatusGatewayTimeout(message string) *APIException
- func StatusInternalServerError() *APIException
- func StatusNotFound(message string) *APIException
- func StatusNotImplemented(message string) *APIException
- func StatusServiceUnavailable(message string) *APIException
- func StatusUnauthorized(message string) *APIException
- func UnknownError(message string) *APIException
- type HandlerFunc
- type Response
Constants ¶
View Source
const ( SERVER_ERROR = 10000 //系統錯誤 NOT_FOUND = 10001 //找不到頁面 UNKNOWN_ERROR = 10002 //未知的錯誤 PARAMETER_ERROR = 10003 //參數錯誤 AUTH_ERROR = 10004 //驗證錯誤 NO_CONTENT = 10005 //沒有內容 DUPLICATE_ERROR = 10006 //重複資料 SUCCESS = 20000 //運行成功 CREATED = 20001 //建立成功 ACCEPT = 20002 //允許操作 )
Variables ¶
This section is empty.
Functions ¶
func StatusText ¶
func Wrapper ¶
func Wrapper(handler HandlerFunc) func(c *gin.Context)
Wrapper 在 register routing 時加入錯誤 handler
Types ¶
type APIException ¶
type APIException struct { Code int `json:"-"` ErrorCode int `json:"code"` Message string `json:"message"` Request string `json:"request"` }
func StatusBadRequest ¶
func StatusBadRequest(message string) *APIException
400 系列
StatusBadRequest 400
func StatusGatewayTimeout ¶
func StatusGatewayTimeout(message string) *APIException
StatusGatewayTimeout 504
func StatusInternalServerError ¶
func StatusInternalServerError() *APIException
500 系列
ServerError 500 伺服器錯誤
func StatusNotImplemented ¶
func StatusNotImplemented(message string) *APIException
StatusNotImplemented 501
func StatusServiceUnavailable ¶
func StatusServiceUnavailable(message string) *APIException
StatusServiceUnavailable 503
func StatusUnauthorized ¶
func StatusUnauthorized(message string) *APIException
StatusUnauthorized 401
func (*APIException) Error ¶
func (e *APIException) Error() string
Click to show internal directories.
Click to hide internal directories.