Documentation ¶
Index ¶
- func Abort(w http.ResponseWriter, f string, args ...interface{})
- func AddFilter(filter Filter)
- func NameToPath(name string, depth int) string
- func ParseFormVars(req *http.Request, result interface{}) error
- func ParseHeaderVars(req *http.Request, result interface{}) error
- func ParseJSONVars(req *http.Request, result interface{}) error
- func ParseURLVars(req *http.Request, result interface{}) error
- func Register(obj interface{}) error
- func RegisterHandler(call func(http.ResponseWriter, *http.Request), method, path string) error
- func RegisterMust(obj interface{})
- func RegisterPath(obj interface{}, path string) error
- func RegisterPathMust(obj interface{}, path string)
- func RegisterPrefix(obj interface{}, path string) error
- func RegisterPrefixMust(obj interface{}, path string)
- func SendData(w http.ResponseWriter, data interface{})
- func SendErrorDetail(w http.ResponseWriter, status int, data interface{}, f string, ...)
- func SendResponse(w http.ResponseWriter, status int, f string, args ...interface{})
- func SendResponseData(w http.ResponseWriter, data interface{})
- func SendResponseOK(w http.ResponseWriter)
- func SendRows(w http.ResponseWriter, total interface{}, data interface{})
- func Start(addr string) (net.Listener, error)
- func UnmarshalForm(req *http.Request, postion VariablePostion, result interface{}) error
- func UnmarshalJSON(req *http.Request, result interface{}) error
- func UnmarshalValidate(req *http.Request, postion VariablePostion, result interface{}) error
- type Filter
- type Method
- type Response
- type VariablePostion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseFormVars ¶
ParseFormVars 解析并验证Form表单中参数.
func ParseHeaderVars ¶
ParseHeaderVars 解析并验证头中参数.
func ParseJSONVars ¶
ParseJSONVars 解析并验证Body中的Json参数.
func ParseURLVars ¶
ParseURLVars 解析并验证头中参数.
func Register ¶
func Register(obj interface{}) error
Register 只要struct实现了Get(),Post(),Delete(),Put()接口就可以自动注册
func RegisterHandler ¶ added in v1.2.0
RegisterHandler 注册自定义url完全匹配.
func RegisterMust ¶ added in v1.6.2
func RegisterMust(obj interface{})
RegisterMust 只要struct实现了Get(),Post(),Delete(),Put()接口就可以自动注册, 如果添加失败panic.
func RegisterPathMust ¶ added in v1.6.2
func RegisterPathMust(obj interface{}, path string)
RegisterPathMust 注册url完全匹配,如果遇到错误panic.
func RegisterPrefix ¶
RegisterPrefix 注册url前缀.
func RegisterPrefixMust ¶ added in v1.6.2
func RegisterPrefixMust(obj interface{}, path string)
RegisterPrefixMust 注册url前缀并保证成功.
func SendData ¶ added in v1.1.1
func SendData(w http.ResponseWriter, data interface{})
SendData 为bootstrap-talbe客户端分页返回结果.
func SendErrorDetail ¶
func SendErrorDetail(w http.ResponseWriter, status int, data interface{}, f string, args ...interface{})
SendErrorDetail 返回详细的错误信息,支持json
func SendResponse ¶
func SendResponse(w http.ResponseWriter, status int, f string, args ...interface{})
SendResponse 返回结果,支持json
func SendResponseData ¶
func SendResponseData(w http.ResponseWriter, data interface{})
SendResponseData 返回结果,支持json
func SendRows ¶
func SendRows(w http.ResponseWriter, total interface{}, data interface{})
SendRows 为bootstrap-talbe返回结果,根据条件查找,total是总记录数,rows是数据
func UnmarshalForm ¶
func UnmarshalForm(req *http.Request, postion VariablePostion, result interface{}) error
UnmarshalForm 解析form中或者url中参数, 只支持int和string.
func UnmarshalJSON ¶
UnmarshalJSON 解析body中的json数据.
func UnmarshalValidate ¶
func UnmarshalValidate(req *http.Request, postion VariablePostion, result interface{}) error
UnmarshalValidate 解析并检证参数.
Types ¶
type Response ¶
type Response struct { Status int Message string `json:",omitempty"` Data interface{} `json:",omitempty"` }
Response 通用返回结果
type VariablePostion ¶
type VariablePostion int
VariablePostion 变量位置.
const ( //URI 参数在uri里. URI VariablePostion = iota //HEADER 参数在头里. HEADER //JSON 参数在body的json里. JSON //FORM 参数在form表单中. FORM )