Documentation
¶
Index ¶
- Variables
- func AddActionGroup(groupPath string, actionFunc ActionGroupFunc)
- func AddActionGroupDeprecated(groupPath string, actionFunc ActionGroupFunc)
- func ErrorFetcher() middleware.MiddewareFunc
- func Get(url string) (respStr string, e error)
- func GetByProxy(webUrl, proxyUrl string) (respStr string, e error)
- func GetJ(url string, v interface{}) (e error)
- func HerArgInvalid(argName string) (HttpErrReturn, StatusCode)
- func HerData(str string) (HttpErrReturn, StatusCode)
- func HerDeprecated() (HttpErrReturn, StatusCode)
- func HerOk() (HttpErrReturn, StatusCode)
- func HerOkWithData(data interface{}) (HttpErrReturn, StatusCode)
- func HerOkWithDataAndUsedTime(data interface{}, time time.Duration) (HttpErrReturn, StatusCode)
- func HerOkWithString(str string) (HttpErrReturn, StatusCode)
- func HerRaw()
- func HttpRecoverBasic(w *http.ResponseWriter, re interface{})
- func HttpReturn(w *http.ResponseWriter, desc, errCode, data string, MakeHERxxx MakeHERxxx)
- func HttpReturnArgInvalid(w *http.ResponseWriter, argName string)
- func HttpReturnHER(w *http.ResponseWriter, her *HttpErrReturn, statusCode StatusCode, url string)
- func HttpReturnOk(w *http.ResponseWriter)
- func HttpReturnOkWithData(w *http.ResponseWriter, data string)
- func PostByProxy(webUrl string, body interface{}, v interface{}, proxyUrl string) (e error)
- func PostJ(u string, body interface{}, v interface{}) (e error)
- func RegisterActions() error
- func TrafficGuard() middleware.MiddewareFunc
- type ActionFunc
- type ActionFuncWS
- type ActionGroup
- func (a ActionGroup) Deprecated(substitute string) ActionGroup
- func (a ActionGroup) GET(path string, handler ActionFunc)
- func (a ActionGroup) GET_CONTENT(path string, handler ActionFunc)
- func (a ActionGroup) GET_DO(path string, handler ActionFunc)
- func (a ActionGroup) IsDeprecated(path string) bool
- func (a ActionGroup) POST(path string, handler ActionFunc)
- func (a ActionGroup) POST_CONTENT(path string, handler ActionFunc)
- func (a ActionGroup) SetFreq(freqPerSec float64) ActionGroup
- func (a ActionGroup) WS(path string, handler ActionFuncWS)
- type ActionGroupFunc
- type ActionPackage
- type ActionPackageWS
- func (pR *ActionPackageWS) ReadBinary() ([]byte, error)
- func (pR *ActionPackageWS) ReadJson(v interface{}) (e error)
- func (pR *ActionPackageWS) ReadString() (string, error)
- func (pR *ActionPackageWS) WriteBinary(b []byte) (e error)
- func (pR *ActionPackageWS) WriteJson(data interface{}) (e error)
- func (pR *ActionPackageWS) WriteString(str string) (e error)
- type H
- type HttpErrReturn
- func MakeHER(desc, errcode string) *HttpErrReturn
- func MakeHER200(desc, errcode string) (*HttpErrReturn, int)
- func MakeHER400(desc, errcode string) (*HttpErrReturn, int)
- func MakeHER401(desc, errcode string) (*HttpErrReturn, int)
- func MakeHER404(desc, errcode string) (*HttpErrReturn, int)
- func MakeHER500(desc, errcode string) (*HttpErrReturn, int)
- type MakeHERxxx
- type StatusCode
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ContentType map[string]string ActionGroups map[string]ActionGroup )
Functions ¶
func AddActionGroup ¶
func AddActionGroup(groupPath string, actionFunc ActionGroupFunc)
添加一个业务逻辑组 所有的 action 将在 RegisterActions() 被调用时启用
func AddActionGroupDeprecated ¶
func AddActionGroupDeprecated(groupPath string, actionFunc ActionGroupFunc)
func GetByProxy ¶
func HerArgInvalid ¶
func HerArgInvalid(argName string) (HttpErrReturn, StatusCode)
func HerDeprecated ¶
func HerDeprecated() (HttpErrReturn, StatusCode)
用于在弃用的API中直接返回 请使用( a ActionGroup ) Deprecated
func HerOkWithData ¶
func HerOkWithData(data interface{}) (HttpErrReturn, StatusCode)
data将会自动转化为json
func HerOkWithDataAndUsedTime ¶
func HerOkWithDataAndUsedTime(data interface{}, time time.Duration) (HttpErrReturn, StatusCode)
携带花费时间 Data块会分为 raw 与 usedTime 标记;raw 装载原始数据,usedTime 装载运行所用时间,单位为秒
func HttpRecoverBasic ¶
func HttpRecoverBasic(w *http.ResponseWriter, re interface{})
func HttpReturn ¶
func HttpReturn(w *http.ResponseWriter, desc, errCode, data string, MakeHERxxx MakeHERxxx)
func HttpReturnArgInvalid ¶
func HttpReturnArgInvalid(w *http.ResponseWriter, argName string)
func HttpReturnHER ¶
func HttpReturnHER(w *http.ResponseWriter, her *HttpErrReturn, statusCode StatusCode, url string)
func HttpReturnOk ¶
func HttpReturnOk(w *http.ResponseWriter)
func HttpReturnOkWithData ¶
func HttpReturnOkWithData(w *http.ResponseWriter, data string)
func PostByProxy ¶
func TrafficGuard ¶
func TrafficGuard() middleware.MiddewareFunc
Types ¶
type ActionFunc ¶
type ActionFunc func(ActionPackage) (HttpErrReturn, StatusCode)
type ActionFuncWS ¶
type ActionFuncWS func(ActionPackage, ActionPackageWS) error
type ActionGroup ¶
func (ActionGroup) Deprecated ¶
func (a ActionGroup) Deprecated(substitute string) ActionGroup
用于弃用某个API并提示使用新API
func (ActionGroup) GET_CONTENT ¶
func (a ActionGroup) GET_CONTENT(path string, handler ActionFunc)
用于返回content内容
func (ActionGroup) GET_DO ¶
func (a ActionGroup) GET_DO(path string, handler ActionFunc)
只返回data,不返回其他的任何信息 DO: DATA ONLY
func (ActionGroup) IsDeprecated ¶
func (a ActionGroup) IsDeprecated(path string) bool
func (ActionGroup) POST_CONTENT ¶
func (a ActionGroup) POST_CONTENT(path string, handler ActionFunc)
用于返回content内容
func (ActionGroup) SetFreq ¶
func (a ActionGroup) SetFreq(freqPerSec float64) ActionGroup
func (ActionGroup) WS ¶
func (a ActionGroup) WS(path string, handler ActionFuncWS)
添加一个websocket请求 cc规范:必须在请求路径末端添加ws字段来提示这一请求为websocket请求 例:/imai_mami/no/koto/ga/suki/ws
type ActionGroupFunc ¶
type ActionGroupFunc func(ActionGroup) error
type ActionPackage ¶
type ActionPackage struct { R *http.Request W *http.ResponseWriter }
func (ActionPackage) GetBodyUnmarshal ¶
func (R ActionPackage) GetBodyUnmarshal(v interface{}) error
func (ActionPackage) GetFormValue ¶
func (R ActionPackage) GetFormValue(key string) string
func (*ActionPackage) SetCookie ¶
func (pap *ActionPackage) SetCookie(cookie *http.Cookie)
type ActionPackageWS ¶
func (*ActionPackageWS) ReadBinary ¶
func (pR *ActionPackageWS) ReadBinary() ([]byte, error)
func (*ActionPackageWS) ReadJson ¶
func (pR *ActionPackageWS) ReadJson(v interface{}) (e error)
将ws读取数据转化为json error总是断连错误
func (*ActionPackageWS) ReadString ¶
func (pR *ActionPackageWS) ReadString() (string, error)
将ws的读取数据转化为字符串
func (*ActionPackageWS) WriteBinary ¶
func (pR *ActionPackageWS) WriteBinary(b []byte) (e error)
func (*ActionPackageWS) WriteJson ¶
func (pR *ActionPackageWS) WriteJson(data interface{}) (e error)
func (*ActionPackageWS) WriteString ¶
func (pR *ActionPackageWS) WriteString(str string) (e error)
type HttpErrReturn ¶
type HttpErrReturn struct { ErrCod string // 内部错误代码,与http状态码不同见第四行 Desc string // 错误描述 Data string // 携带数据 }
用于返回http状态信息,格式为json
func MakeHER400 ¶
func MakeHER400(desc, errcode string) (*HttpErrReturn, int)
server Bad Request 请求非法,请检查错误信息后重试
func MakeHER401 ¶
func MakeHER401(desc, errcode string) (*HttpErrReturn, int)
server Unauthorized 未授权
func MakeHER404 ¶
func MakeHER404(desc, errcode string) (*HttpErrReturn, int)
server Not Found 没有这个资源
func MakeHER500 ¶
func MakeHER500(desc, errcode string) (*HttpErrReturn, int)
server Server Error 服务器内部错误
type MakeHERxxx ¶
type MakeHERxxx func(desc, errcode string) (*HttpErrReturn, int)
用于返回http状态信息,格式为json
Source Files
¶
Click to show internal directories.
Click to hide internal directories.