Documentation
¶
Index ¶
- Constants
- Variables
- type DefaultResponse
- type FailBodyError
- type FailResponseError
- type JSendErrorBody
- type JSendFailBody
- type JSendSuccessBody
- type Response
- func NewJSendErrorDebugResponse(message string, debugMessage string, code *string, httpStatus int) Response
- func NewJSendErrorResponse(message string, code *string, httpStatus int) Response
- func NewJSendFailResponse(data interface{}, code *string, httpStatus int) Response
- func NewJSendSuccessResponse(data interface{}, httpStatus int) Response
- type Status
Constants ¶
const (
ErrInvalidFieldValueType = "invalid field value type, expected: '%s'"
)
Variables ¶
var ( ErrNilResponse = errors.New("response cannot be nil") ErrNilFailBodyError = errors.New("fail body error cannot be nil") )
Functions ¶
This section is empty.
Types ¶
type DefaultResponse ¶ added in v0.9.5
type DefaultResponse struct {
// contains filtered or unexported fields
}
DefaultResponse struct
func NewDebugResponse ¶ added in v0.4.6
func NewDebugResponse(
body interface{},
debugBody interface{},
httpStatus int,
) *DefaultResponse
NewDebugResponse creates a new debug response
Parameters:
- body: The response body
- debugBody: The debug response body
- httpStatus: The HTTP status
Returns:
- *DefaultResponse: The default response
func NewResponse ¶ added in v0.3.0
func NewResponse(
body interface{},
httpStatus int,
) *DefaultResponse
NewResponse creates a new response
Parameters:
- body: The response body
- httpStatus: The HTTP status
Returns:
- *DefaultResponse: The default response
func (DefaultResponse) Body ¶ added in v0.9.5
func (d DefaultResponse) Body(mode *goflagsmode.Flag) interface{}
Body returns the response body
Parameters:
- mode: The flag mode
Returns:
- interface{}: The response body
func (DefaultResponse) HTTPStatus ¶ added in v0.9.5
func (d DefaultResponse) HTTPStatus() int
HTTPStatus returns the HTTP status
Returns:
- int: The HTTP status
type FailBodyError ¶ added in v0.9.5
type FailBodyError struct {
// contains filtered or unexported fields
}
FailBodyError struct
func NewFailBodyError ¶ added in v0.9.5
func NewFailBodyError( key, err string, errorCode *string, ) *FailBodyError
NewFailBodyError creates a new fail body error
Parameters:
- key: The key of the fail body error
- err: The error of the fail body error
- errorCode: The error code of the fail body error
Returns:
- *FailBodyError: The fail body error
func (FailBodyError) Body ¶ added in v0.9.7
func (f FailBodyError) Body() *JSendFailBody
Body returns a response body from the fail body error
Returns:
- *JSendFailBody: The response body
func (FailBodyError) Data ¶ added in v0.9.7
func (f FailBodyError) Data() map[string][]string
Data returns a response data map from the fail body error
Returns:
- map[string][]string: The response data map
func (FailBodyError) Error ¶ added in v0.9.5
func (f FailBodyError) Error() string
Error returns the error of the fail body error
Returns:
- string: The error of the fail body error
func (FailBodyError) ErrorCode ¶ added in v0.9.5
func (f FailBodyError) ErrorCode() *string
ErrorCode returns the error code of the fail body error
Returns:
- *string: The error code of the fail body error
func (FailBodyError) Key ¶ added in v0.9.5
func (f FailBodyError) Key() string
Key returns the key of the fail body error
Returns:
- string: The key of the fail body error
type FailResponseError ¶ added in v0.9.5
type FailResponseError struct {
FailBodyError
// contains filtered or unexported fields
}
FailResponseError struct
func NewFailResponseError ¶ added in v0.9.5
func NewFailResponseError( key, err string, errorCode *string, httpStatus int, ) *FailResponseError
NewFailResponseError creates a new fail response error
Parameters:
- key: The key
- err: The error
- errorCode: The error code
- httpStatus: The HTTP status
Returns:
- *FailResponseError: The fail response error
func (FailResponseError) Error ¶ added in v0.9.5
func (f FailResponseError) Error() string
Error returns the error of the fail response error
Returns:
- string: The error
func (FailResponseError) ErrorCode ¶ added in v0.9.5
func (f FailResponseError) ErrorCode() *string
ErrorCode returns the error code of the fail response error
Returns:
- *string: The error code
func (FailResponseError) HTTPStatus ¶ added in v0.9.5
func (f FailResponseError) HTTPStatus() int
HTTPStatus returns the http status of the fail response error
Returns:
- int: The http status
func (FailResponseError) Key ¶ added in v0.9.5
func (f FailResponseError) Key() string
Key returns the key of the fail response error
Returns:
- string: The key
func (FailResponseError) Response ¶ added in v0.9.7
func (f FailResponseError) Response() Response
Response creates a new response from a fail response error
Returns:
- Response: The response
type JSendErrorBody ¶ added in v0.6.0
type JSendErrorBody struct {
Status Status `json:"status"`
Message *string `json:"message,omitempty"`
Code *string `json:"code,omitempty"`
}
JSendErrorBody struct
func NewJSendErrorBody ¶ added in v0.5.17
NewJSendErrorBody creates a new JSend error response body
Parameters:
- message: The error message
- code: The error code
Returns:
- *JSendErrorBody: The JSend error body
type JSendFailBody ¶ added in v0.6.0
type JSendFailBody struct {
Status Status `json:"status"`
Code *string `json:"code,omitempty"`
Data interface{} `json:"data,omitempty"`
}
JSendFailBody struct
func NewJSendFailBody ¶ added in v0.5.17
func NewJSendFailBody(
data interface{},
code *string,
) *JSendFailBody
NewJSendFailBody creates a new JSend fail response body
Parameters:
- data: The data
- code: The error code
Returns:
- *JSendFailBody: The JSend fail body
type JSendSuccessBody ¶ added in v0.6.0
type JSendSuccessBody[T interface{}] struct {
Status Status `json:"status"`
Data T `json:"data,omitempty"`
}
JSendSuccessBody struct
func NewJSendSuccessBody ¶ added in v0.5.17
func NewJSendSuccessBody[T interface{}](
data T,
) *JSendSuccessBody[T]
NewJSendSuccessBody creates a new JSend success response body
Parameters:
- data: The data
Returns:
- *JSendSuccessBody: The JSend success body
type Response ¶ added in v0.3.0
type Response interface {
Body(mode *goflagsmode.Flag) interface{}
HTTPStatus() int
}
Response is the interface for the responses
func NewJSendErrorDebugResponse ¶ added in v0.9.6
func NewJSendErrorDebugResponse( message string, debugMessage string, code *string, httpStatus int, ) Response
NewJSendErrorDebugResponse creates a new JSend error response with debug information
Parameters:
- message: The error message
- debugMessage: The debug message
- code: The error code
- httpStatus: The HTTP status code
Returns:
- Response: The response
func NewJSendErrorResponse ¶ added in v0.5.0
NewJSendErrorResponse creates a new JSend error response
Parameters:
- message: The error message
- code: The error code
- httpStatus: The HTTP status code
Returns:
- Response: The response
func NewJSendFailResponse ¶ added in v0.5.0
NewJSendFailResponse creates a new JSend fail response
Parameters:
- data: The data
- code: The error code
- httpStatus: The HTTP status code
Returns:
- Response: The response
func NewJSendSuccessResponse ¶ added in v0.5.0
NewJSendSuccessResponse creates a new JSend success response
Parameters:
- data: The data
- httpStatus: The HTTP status code
Returns:
- Response: The response