Documentation
¶
Index ¶
- func NewDebugErrorResponse(message string, debugMessage string, httpStatus int) gonethttpresponse.Response
- func NewDebugErrorResponseWithCode(message string, debugMessage string, code string, httpStatus int) gonethttpresponse.Response
- func NewErrorResponse(message string, httpStatus int) gonethttpresponse.Response
- func NewErrorResponseWithCode(message string, code string, httpStatus int) gonethttpresponse.Response
- func NewFailResponse(data interface{}, httpStatus int) gonethttpresponse.Response
- func NewFailResponseWithCode(data interface{}, code string, httpStatus int) gonethttpresponse.Response
- func NewResponseFromError(err *gonethttpresponse.Error) gonethttpresponse.Response
- func NewResponseFromFailDataError(failDataErr *gonethttpresponse.FailDataError) gonethttpresponse.Response
- func NewResponseFromFailFieldError(failErr *gonethttpresponse.FailFieldError) gonethttpresponse.Response
- func NewSuccessResponse(data interface{}, httpStatus int) gonethttpresponse.Response
- type ErrorBody
- type FailBody
- type Status
- type SuccessBody
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDebugErrorResponse ¶
func NewDebugErrorResponse( message string, debugMessage string, httpStatus int, ) gonethttpresponse.Response
NewDebugErrorResponse creates a new JSend error response with debug information
Parameters:
- message: The error message
- debugMessage: The debug message
- httpStatus: The HTTP status code
Returns:
- Response: The response
func NewDebugErrorResponseWithCode ¶
func NewDebugErrorResponseWithCode( message string, debugMessage string, code string, httpStatus int, ) gonethttpresponse.Response
NewDebugErrorResponseWithCode creates a new JSend error response with debug information and error code
Parameters:
- message: The error message
- debugMessage: The debug message
- code: The error code
- httpStatus: The HTTP status code
Returns:
- Response: The response
func NewErrorResponse ¶
func NewErrorResponse( message string, httpStatus int, ) gonethttpresponse.Response
NewErrorResponse creates a new JSend error response
Parameters:
- message: The error message
- httpStatus: The HTTP status code
Returns:
- Response: The response
func NewErrorResponseWithCode ¶
func NewErrorResponseWithCode( message string, code string, httpStatus int, ) gonethttpresponse.Response
NewErrorResponseWithCode creates a new JSend error response with error code
Parameters:
- message: The error message
- code: The error code
- httpStatus: The HTTP status code
Returns:
- Response: The response
func NewFailResponse ¶
func NewFailResponse(
data interface{},
httpStatus int,
) gonethttpresponse.Response
NewFailResponse creates a new JSend fail response
Parameters:
- data: The data
- httpStatus: The HTTP status code
Returns:
- Response: The response
func NewFailResponseWithCode ¶
func NewFailResponseWithCode(
data interface{},
code string,
httpStatus int,
) gonethttpresponse.Response
NewFailResponseWithCode creates a new JSend fail response with error code
Parameters:
- data: The data
- code: The error code
- httpStatus: The HTTP status code
Returns:
- Response: The response
func NewResponseFromError ¶
func NewResponseFromError(err *gonethttpresponse.Error) gonethttpresponse.Response
NewResponseFromError creates a new JSend response from an error
Parameters:
- err: The error to convert to a response
Returns:
- Response: The response
func NewResponseFromFailDataError ¶
func NewResponseFromFailDataError(failDataErr *gonethttpresponse.FailDataError) gonethttpresponse.Response
NewResponseFromFailDataError creates a new JSend response from a fail data error
Parameters:
- failDataErr: The fail data error to convert to a response
Returns:
- Response: The response
func NewResponseFromFailFieldError ¶
func NewResponseFromFailFieldError(failErr *gonethttpresponse.FailFieldError) gonethttpresponse.Response
NewResponseFromFailFieldError creates a new JSend response from a fail error
Parameters:
- failErr: The fail error to convert to a response
Returns:
- Response: The response
func NewSuccessResponse ¶
func NewSuccessResponse(
data interface{},
httpStatus int,
) gonethttpresponse.Response
NewSuccessResponse creates a new JSend success response
Parameters:
- data: The data
- httpStatus: The HTTP status code
Returns:
- Response: The response
Types ¶
type ErrorBody ¶
type ErrorBody struct {
Status Status `json:"status"`
Message string `json:"message,omitempty"`
Code string `json:"code,omitempty"`
}
ErrorBody struct
func NewErrorBody ¶
NewErrorBody creates a new JSend error response body
Parameters:
- message: The error message
Returns:
- *ErrorBody: The JSend error body
func NewErrorBodyWithCode ¶
NewErrorBodyWithCode creates a new JSend error response body with error code
Parameters:
- message: The error message
- code: The error code
Returns:
- *ErrorBody: The JSend error body
type FailBody ¶
type FailBody struct {
Status Status `json:"status"`
Code string `json:"code,omitempty"`
Data interface{} `json:"data,omitempty"`
}
FailBody struct
func NewFailBody ¶
func NewFailBody(
data interface{},
) *FailBody
NewFailBody creates a new JSend fail response body
Parameters:
- data: The data
Returns:
func NewFailBodyWithCode ¶
NewFailBodyWithCode creates a new JSend fail response body with error code
Parameters:
- data: The data
- code: The error code
Returns:
- *FailBody: The JSend fail body
type SuccessBody ¶
type SuccessBody[T interface{}] struct {
Status Status `json:"status"`
Data T `json:"data,omitempty"`
}
SuccessBody struct
func NewSuccessBody ¶
func NewSuccessBody[T interface{}](
data T,
) *SuccessBody[T]
NewSuccessBody creates a new JSend success response body
Parameters:
- data: The data
Returns:
- *SuccessBody: The JSend success body