Documentation ¶
Index ¶
- Constants
- Variables
- func DetectCode(err error) int
- func DetectError(err error) (code int, desc string)
- func DetectErrorCode(err error) string
- func Error(w http.ResponseWriter, err error)
- func ErrorWithCT(w http.ResponseWriter, err error, contentType string)
- func Flusher(w http.ResponseWriter) (f http.Flusher, ok bool)
- func GetCloseNotifier(w http.ResponseWriter) (cn http.CloseNotifier, ok bool)
- func GetCloseNotifierSafe(w http.ResponseWriter) http.CloseNotifier
- func GetHijacker(w http.ResponseWriter) (hj http.Hijacker, ok bool)
- func HijackClose(xl *xlog.Logger, w http.ResponseWriter)
- func NewCodeError(code int) error
- func Reply(w http.ResponseWriter, code int, data interface{})
- func ReplyErr(w http.ResponseWriter, code int, err string)
- func ReplyError(w http.ResponseWriter, err string, code int)
- func ReplyErrorCode(w http.ResponseWriter, code int, errCode, err string)
- func ReplyWith(w http.ResponseWriter, code int, bodyType string, msg []byte)
- func ReplyWithCode(w http.ResponseWriter, code int)
- func ReplyWithStream(w http.ResponseWriter, code int, bodyType string, body io.Reader, bytes int64)
- type Errno
- type ErrorInfo
- type ErrorRet
- type RequestCanceler
Constants ¶
View Source
const ( StatusGracefulQuit = 570 // 停止服务中(重启中) StatusOverload = 571 // 过载保护阶段(处理部分请求,其余返回 571 重试码) StatusAbnormal = 572 // 认为自身工作不正常时,比如长时间没法拿到数据 StatusOutOfQuota = 573 // 客户端请求超出限制,拒绝请求报573 )
Variables ¶
View Source
var ( ErrGracefulQuit = NewError(StatusGracefulQuit, "graceful quit") ErrOverload = NewError(StatusOverload, "overload") ErrOutOfConcurrentQuota = NewError(StatusOutOfQuota, "out of concurrent quota") ErrOutOfRequestQuota = NewError(StatusOutOfQuota, "out of request quota") ErrOutOfFlowQuota = NewError(StatusOutOfQuota, "out of flow quota") )
Functions ¶
func DetectCode ¶
func DetectError ¶
func DetectErrorCode ¶
func Error ¶
func Error(w http.ResponseWriter, err error)
func ErrorWithCT ¶
func ErrorWithCT(w http.ResponseWriter, err error, contentType string)
func GetCloseNotifier ¶
func GetCloseNotifier(w http.ResponseWriter) (cn http.CloseNotifier, ok bool)
deprecated: use http.Request.Context()
func GetCloseNotifierSafe ¶
func GetCloseNotifierSafe(w http.ResponseWriter) http.CloseNotifier
deprecated: use http.Request.Context()
func GetHijacker ¶
func GetHijacker(w http.ResponseWriter) (hj http.Hijacker, ok bool)
func NewCodeError ¶
func Reply ¶
func Reply(w http.ResponseWriter, code int, data interface{})
func ReplyError ¶
func ReplyError(w http.ResponseWriter, err string, code int)
func ReplyErrorCode ¶
func ReplyErrorCode(w http.ResponseWriter, code int, errCode, err string)
func ReplyWithCode ¶
func ReplyWithCode(w http.ResponseWriter, code int)
func ReplyWithStream ¶
Types ¶
type ErrorInfo ¶
func NewErrorCode ¶
type RequestCanceler ¶
func GetRequestCanceler ¶
func GetRequestCanceler(tp http.RoundTripper) (rc RequestCanceler, ok bool)
deprecated: use http.Request.WithContext()
Click to show internal directories.
Click to hide internal directories.