Documentation ¶
Index ¶
- func GetRandomUserAgent() string
- func IsValidUrl(str string) bool
- type Client
- type GinHandle
- func (*GinHandle) DefaultQuery(c *gin.Context, key string, defaultValue string) string
- func (*GinHandle) FormFile(c *gin.Context, key string) (*multipart.FileHeader, error)
- func (*GinHandle) Param(c *gin.Context, key string) string
- func (*GinHandle) Query(c *gin.Context, key string) string
- func (*GinHandle) RequestFormFile(c *gin.Context, key string) (multipart.File, *multipart.FileHeader, error)
- func (*GinHandle) RetuenHTML(c *gin.Context, name string, data interface{})
- func (*GinHandle) RetuenOk(c *gin.Context, data interface{})
- func (*GinHandle) ReturnErr(c *gin.Context, r *replyx.T)
- func (*GinHandle) ReturnHTML(c *gin.Context, name string, data interface{})
- func (*GinHandle) ReturnJSON(c *gin.Context, code int, data interface{})
- func (*GinHandle) ReturnOk(c *gin.Context, data interface{})
- func (*GinHandle) ReturnStatusOKErr(c *gin.Context, r *replyx.T)
- func (*GinHandle) ShouldBind(c *gin.Context, s interface{}) error
- func (*GinHandle) ShouldBindJSON(c *gin.Context, s interface{}) error
- func (*GinHandle) ShouldBindUri(c *gin.Context, s interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRandomUserAgent ¶ added in v0.10.1
func GetRandomUserAgent() string
GetRandomUserAgent 获取随机User-Agent
Types ¶
type Client ¶
type GinHandle ¶ added in v0.0.4
type GinHandle struct{}
func (*GinHandle) DefaultQuery ¶ added in v0.0.4
DefaultQuery 获取get参数,如果没有则返回默认值 例如:/user?name=xxx => DefaultQuery(c, "name", "default")
func (*GinHandle) RequestFormFile ¶ added in v0.5.0
func (*GinHandle) RequestFormFile(c *gin.Context, key string) (multipart.File, *multipart.FileHeader, error)
RequestFormFile 获取上传文件 例如:RequestFormFile(c, "file")
func (*GinHandle) RetuenHTML ¶ added in v0.5.3
RetuenHTML 返回html 例如:RetuenHTML(c, "index.html", data)
func (*GinHandle) RetuenOk ¶ added in v0.0.5
RetuenOk 返回成功json 例如:RetuenOk(c, data) => ReturnJSON(c, http.StatusOK, respx.Succ(data))
func (*GinHandle) ReturnErr ¶ added in v0.0.5
ReturnErr 返回错误json 例如:ReturnErr(c, respx.ParamErrT.ToPt()) => ReturnJSON(c, http.StatusBadRequest, respx.ParamErrT.ToPt())
func (*GinHandle) ReturnHTML ¶ added in v0.10.7
ReturnHTML 返回html 例如:ReturnHTML(c, "index.html", data)
func (*GinHandle) ReturnJSON ¶ added in v0.0.5
ReturnJSON 返回json 例如:ReturnJSON(c, http.StatusOK, respx.Succ(data))
func (*GinHandle) ReturnOk ¶ added in v0.10.7
ReturnOk 返回成功json 例如:ReturnOk(c, data) => ReturnJSON(c, http.StatusOK, respx.Succ(data))
func (*GinHandle) ReturnStatusOKErr ¶ added in v0.9.5
ReturnStatusOKErr 返回错误json(http=200) 例如:ReturnStatusOKErr(c, respx.ParamErrT.ToPt()) => ReturnJSON(c, http.StatusOK, respx.ParamErrT.ToPt())
func (*GinHandle) ShouldBind ¶ added in v0.0.4
ShouldBind Get绑定到结构体 例如:
type DemoGetReq struct { Id int `form:"id"` // 必须有form标签 }
var r req.DemoGetReq /user?name=xxx => ShouldBind(c, &r)
func (*GinHandle) ShouldBindJSON ¶ added in v0.0.4
ShouldBindJSON Post绑定到结构体 例如:
type DemoPostReq struct { Id int `json:"id"` // 必须有json标签,application/json }
var r req.DemoPostReq /user => ShouldBindJSON(c, &r)