response

package
v0.9.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2025 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilResponse           = errors.New("response cannot be nil")
	ErrInvalidFieldValueType = "invalid field value type, expected: '%s'"
)

Functions

func NewDataFromFailBodyError added in v0.9.5

func NewDataFromFailBodyError(
	failBodyError *FailBodyError,
) *map[string]*[]string

NewDataFromFailBodyError creates a new data map from fail body error

Types

type BaseJSendBody added in v0.9.5

type BaseJSendBody struct {
	Status  string  `json:"status"`
	Message *string `json:"message,omitempty"`
	Code    *string `json:"code,omitempty"`
}

BaseJSendBody struct. The 'data' field must be defined on derived structs of this base struct.

func NewBaseJSendErrorBody added in v0.9.5

func NewBaseJSendErrorBody(
	message string,
	code *string,
) *BaseJSendBody

NewBaseJSendErrorBody creates a new base JSend error response body

func NewBaseJSendFailBody added in v0.9.5

func NewBaseJSendFailBody(
	code *string,
) *BaseJSendBody

NewBaseJSendFailBody creates a new base JSend fail response body

func NewBaseJSendSuccessBody added in v0.9.5

func NewBaseJSendSuccessBody() *BaseJSendBody

NewBaseJSendSuccessBody creates a new base JSend success response body

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

func NewResponse added in v0.3.0

func NewResponse(
	body interface{},
	httpStatus int,
) *DefaultResponse

NewResponse creates a new response

func (*DefaultResponse) Body added in v0.9.5

func (d *DefaultResponse) Body(mode *goflagsmode.Flag) interface{}

Body returns the response body

func (*DefaultResponse) HTTPStatus added in v0.9.5

func (d *DefaultResponse) HTTPStatus() int

HTTPStatus returns 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

func (*FailBodyError) Error added in v0.9.5

func (f *FailBodyError) Error() string

Error returns 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

func (*FailBodyError) Key added in v0.9.5

func (f *FailBodyError) Key() string

Key returns 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

func (*FailResponseError) Error added in v0.9.5

func (f *FailResponseError) Error() string

Error returns the error of the fail response error

func (*FailResponseError) ErrorCode added in v0.9.5

func (f *FailResponseError) ErrorCode() *string

ErrorCode returns the error code of the fail response error

func (*FailResponseError) HTTPStatus added in v0.9.5

func (f *FailResponseError) HTTPStatus() int

HTTPStatus returns the http status of the fail response error

func (*FailResponseError) Key added in v0.9.5

func (f *FailResponseError) Key() string

Key returns the key of the fail response error

type JSendBody added in v0.5.17

type JSendBody struct {
	BaseJSendBody
	Data interface{} `json:"data,omitempty"`
}

JSendBody struct

func NewBodyFromFailBodyError added in v0.9.5

func NewBodyFromFailBodyError(
	failBodyError *FailBodyError,
) *JSendBody

NewBodyFromFailBodyError creates a new body from fail body error

func NewJSendErrorBody added in v0.5.17

func NewJSendErrorBody(
	data interface{},
	message string,
	code *string,
) *JSendBody

NewJSendErrorBody creates a new JSend error response body

func NewJSendFailBody added in v0.5.17

func NewJSendFailBody(
	data interface{},
	code *string,
) *JSendBody

NewJSendFailBody creates a new JSend fail response body

func NewJSendSuccessBody added in v0.5.17

func NewJSendSuccessBody(
	data interface{},
) *JSendBody

NewJSendSuccessBody creates a new JSend success response 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(
	data interface{},
	message string,
	debugMessage string,
	code *string,
	httpStatus int,
) Response

NewJSendErrorDebugResponse creates a new JSend error response with debug information

func NewJSendErrorResponse added in v0.5.0

func NewJSendErrorResponse(
	data interface{},
	message string,
	code *string,
	httpStatus int,
) Response

NewJSendErrorResponse creates a new JSend error response

func NewJSendFailResponse added in v0.5.0

func NewJSendFailResponse(
	data interface{},
	code *string,
	httpStatus int,
) Response

NewJSendFailResponse creates a new JSend fail response

func NewJSendSuccessResponse added in v0.5.0

func NewJSendSuccessResponse(
	data interface{},
	httpStatus int,
) Response

NewJSendSuccessResponse creates a new JSend success response

func NewResponseFromFailResponseError added in v0.9.5

func NewResponseFromFailResponseError(
	failResponseError FailResponseError,
) Response

NewResponseFromFailResponseError creates a new fail response from a fail response error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL