Documentation ¶
Index ¶
- type BaseController
- type Request
- func (req Request) Bool() bool
- func (req Request) GetAllParamsFromUrl() map[string]string
- func (req Request) GetHeader(key string) Request
- func (req Request) GetQuery(key string) Request
- func (req Request) GetQueryDefault(key string, defaultValue string) Request
- func (req Request) GetValidMsg(err error, obj interface{}) string
- func (req Request) IsMimeJson() bool
- func (req Request) PostForm(key string) Request
- func (req Request) PostToModel(obj any) Request
- func (req Request) ShouldBindJSON(obj any)
- func (req Request) ShouldBindQuery(obj any) error
- func (req Request) Value() string
- type ResJson
- type Response
- func (res Response) Fail(code int32, errMsg string)
- func (res Response) Fail400(errMsg string)
- func (res Response) FailAbnormal()
- func (res Response) FailRefuse()
- func (res Response) NilToArray(values interface{}) interface{}
- func (res Response) NilToObj(value interface{}) interface{}
- func (res Response) ResJson(resJson ResJson)
- func (res Response) SetHeader(name string, val string)
- func (res Response) SetSrvHeader()
- func (res Response) Success(data interface{})
- func (res Response) SuccessWithMsg(data interface{}, msg string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseController ¶
func NewBaseController ¶
func NewBaseController(ctx *gin.Context) BaseController
type Request ¶
func NewRequest ¶
func (Request) GetAllParamsFromUrl ¶
GetAllParamsFromUrl 获取url中所有参数, 不支持数组
func (Request) GetQueryDefault ¶
func (Request) GetValidMsg ¶
GetValidMsg 参数校验
func (Request) IsMimeJson ¶
func (Request) PostToModel ¶
func (Request) ShouldBindJSON ¶
ShouldBindJSON 使用注意,只能获取一次,无法重复获取 ShouldBindWith for better performance if you need to call only once.
func (Request) ShouldBindQuery ¶
type ResJson ¶
type ResJson struct { Code int32 `json:"code"` Data interface{} `json:"data"` Message string `json:"message"` }
ResJson 响应的数据结构
type Response ¶
func NewResponse ¶
func (Response) NilToArray ¶
func (res Response) NilToArray(values interface{}) interface{}
NilToArray nil判断,如果是nil 返回空数组
func (Response) NilToObj ¶
func (res Response) NilToObj(value interface{}) interface{}
NilToObj nil判断,如果是nil 返回空对象
func (Response) SetSrvHeader ¶
func (res Response) SetSrvHeader()
SetSrvHeader 设置golang服务器独有请求头,区分PHP/Golang
func (Response) SuccessWithMsg ¶
Click to show internal directories.
Click to hide internal directories.