Documentation ¶
Overview ¶
* 在请求上下文上设置和获取指定的key/val
小助手函数,辅助业务逻辑的函数
* http返回json格式和http code返回处理
Index ¶
- Constants
- func ApiError(w http.ResponseWriter, code int, message string)
- func ApiSuccess(w http.ResponseWriter, message string, data interface{})
- func ContextGet(r *http.Request, key interface{}) interface{}
- func ContextSet(r *http.Request, key, val interface{}) *http.Request
- func GetDeviceByUa(ua string) string
- func GetStringByCtx(ctx context.Context, key string) string
- func HttpCode(w http.ResponseWriter, httpCode int, message string)
- func Json(w http.ResponseWriter, data interface{})
- type EmptyArray
- type H
Constants ¶
View Source
const ( HttpSuccessCode = 200 // http ok 200 HttpErrorCode = 500 // http error 500 ApiSuccessCode = 0 // api success )
Variables ¶
This section is empty.
Functions ¶
func ApiError ¶
func ApiError(w http.ResponseWriter, code int, message string)
ApiError 错误处理code,message
func ApiSuccess ¶
func ApiSuccess(w http.ResponseWriter, message string, data interface{})
ApiSuccess 请求成功返回结果 data,message
func ContextGet ¶
ContextGet 从请求上下文获取指定的key值
func ContextSet ¶
ContextSet 将指定的key/val设置到上下文中
func GetStringByCtx ¶
GetStringByCtx 从上下文获取字符串类型的key
Types ¶
Click to show internal directories.
Click to hide internal directories.