response

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 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'"
	ErrNilFailBodyError      = errors.New("fail body error cannot be nil")
)

Functions

This section is empty.

Types

type BaseJSendErrorBody added in v0.9.7

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

BaseJSendErrorBody struct

func NewBaseJSendErrorBody added in v0.9.5

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

NewBaseJSendErrorBody creates a new base JSend error response body

type BaseJSendFailBody added in v0.9.7

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

BaseJSendFailBody struct

func NewBaseJSendFailBody added in v0.9.5

func NewBaseJSendFailBody(
	code *string,
) *BaseJSendFailBody

NewBaseJSendFailBody creates a new base JSend fail response body

type BaseJSendSuccessBody added in v0.9.7

type BaseJSendSuccessBody struct {
	Status string `json:"status"`
}

BaseJSendSuccessBody struct

func NewBaseJSendSuccessBody added in v0.9.5

func NewBaseJSendSuccessBody() *BaseJSendSuccessBody

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) Body added in v0.9.7

func (f *FailBodyError) Body() *JSendFailBody

Body returns a response body from the fail body error

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

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

func (*FailResponseError) Response added in v0.9.7

func (f *FailResponseError) Response() Response

Response creates a new response from a fail response error

type JSendErrorBody added in v0.6.0

type JSendErrorBody struct {
	BaseJSendErrorBody
	Data interface{} `json:"data,omitempty"`
}

JSendErrorBody struct

func NewJSendErrorBody added in v0.5.17

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

NewJSendErrorBody creates a new JSend error response body

type JSendFailBody added in v0.6.0

type JSendFailBody struct {
	BaseJSendFailBody
	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

type JSendSuccessBody added in v0.6.0

type JSendSuccessBody struct {
	BaseJSendSuccessBody
	Data interface{} `json:"data,omitempty"`
}

JSendSuccessBody struct

func NewJSendSuccessBody added in v0.5.17

func NewJSendSuccessBody(
	data interface{},
) *JSendSuccessBody

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

Jump to

Keyboard shortcuts

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