Documentation ¶
Overview ¶
Package model provides common request and response models.
// UserRequest is the request body type UserRequest struct { model.RequestBody // annotation RequestBody Username string `validate:"required"` Password string `validate:"required"` }
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // RequestTypeBody means it is RequestBody RequestTypeBody = "RequestBody" // RequestTypeParams means it is RequestParams RequestTypeParams = "RequestParams" // RequestTypeForm means it is RequestForm RequestTypeForm = "RequestForm" // Context means it is Context Context = "Context" )
Functions ¶
This section is empty.
Types ¶
type BaseResponse ¶ added in v0.2.0
type BaseResponse struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` }
BaseResponse is the implementation of rest controller's Response
func (*BaseResponse) GetCode ¶ added in v0.2.0
func (r *BaseResponse) GetCode() int
GetCode get error code
func (*BaseResponse) GetData ¶ added in v0.2.0
func (r *BaseResponse) GetData() interface{}
GetData get data
func (*BaseResponse) GetMessage ¶ added in v0.2.0
func (r *BaseResponse) GetMessage() string
GetMessage get message
func (*BaseResponse) SetCode ¶ added in v0.2.0
func (r *BaseResponse) SetCode(code int)
SetCode set error code
func (*BaseResponse) SetData ¶ added in v0.2.0
func (r *BaseResponse) SetData(data interface{})
SetData the data will be serialized to json string
func (*BaseResponse) SetMessage ¶ added in v0.2.0
func (r *BaseResponse) SetMessage(message string)
SetMessage set message
type RequestParams ¶ added in v0.2.0
type RequestParams struct{}
RequestParams the annotation RequestParams
type Response ¶
type Response interface { // Set error code SetCode(code int) // Get error code GetCode() int // Set message SetMessage(message string) // Get message GetMessage() string // Set data, the data will be serialized to json string SetData(data interface{}) // Get data GetData() interface{} }
Response is the interface of rest controller's Response
Click to show internal directories.
Click to hide internal directories.