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 RegisterPath(obj interface{}, path string) error
- func RegisterPrefix(obj interface{}, path string) error
- 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 int64, data interface{})
- func Start(addr string) error
- func Stop() 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 RegisterPrefix ¶
RegisterPrefix 注册url前缀.
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 int64, 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 )
Click to show internal directories.
Click to hide internal directories.