response

package
v0.7.11 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 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 NewRequestErrorBodyData added in v0.5.28

func NewRequestErrorBodyData(
	requestError RequestError,
) *map[string]*[]string

NewRequestErrorBodyData creates a new request errors body data

Types

type ErrorResponse

type ErrorResponse struct {
	// contains filtered or unexported fields
}

ErrorResponse struct

func NewErrorResponse

func NewErrorResponse(
	body interface{},
	debugBody interface{},
	httpStatus int,
) *ErrorResponse

NewErrorResponse creates a new error response

func NewJSendErrorResponse added in v0.5.0

func NewJSendErrorResponse(
	err error,
	debugError error,
	data interface{},
	errorCode *string,
	httpStatus int,
) *ErrorResponse

NewJSendErrorResponse creates a new JSend error response

func (*ErrorResponse) Body added in v0.6.0

func (r *ErrorResponse) Body(mode *goflagsmode.Flag) interface{}

Body returns the response body

func (*ErrorResponse) HTTPStatus added in v0.6.0

func (r *ErrorResponse) HTTPStatus() int

HTTPStatus returns the HTTP status

type FailResponse added in v0.6.0

type FailResponse struct {
	// contains filtered or unexported fields
}

FailResponse struct

func NewFailResponse added in v0.5.0

func NewFailResponse(
	body interface{},
	httpStatus int,
) *FailResponse

NewFailResponse creates a new fail response

func NewJSendFailResponse added in v0.5.0

func NewJSendFailResponse(
	data interface{},
	errorCode *string,
	httpStatus int,
) *FailResponse

NewJSendFailResponse creates a new JSend fail response

func NewResponseFromRequestError added in v0.6.0

func NewResponseFromRequestError(
	requestError RequestError,
) *FailResponse

NewResponseFromRequestError creates a new fail response from a request error

func (*FailResponse) Body added in v0.6.0

func (r *FailResponse) Body(mode *goflagsmode.Flag) interface{}

Body returns the response body

func (*FailResponse) HTTPStatus added in v0.6.0

func (r *FailResponse) HTTPStatus() int

HTTPStatus returns the HTTP status

type FieldError added in v0.5.22

type FieldError struct {
	// contains filtered or unexported fields
}

FieldError struct

func NewFieldError added in v0.5.22

func NewFieldError(
	field, err string, httpStatus int, errorCode *string,
) *FieldError

NewFieldError creates a new field error

func (*FieldError) Error added in v0.5.24

func (f *FieldError) Error() string

Error returns the field error as a string

func (*FieldError) ErrorCode added in v0.5.28

func (f *FieldError) ErrorCode() *string

ErrorCode returns the error code

func (*FieldError) HTTPStatus added in v0.5.28

func (f *FieldError) HTTPStatus() int

HTTPStatus returns the HTTP status

func (*FieldError) Key added in v0.5.26

func (f *FieldError) Key() string

Key returns the field name

type HeaderError added in v0.5.26

type HeaderError struct {
	// contains filtered or unexported fields
}

HeaderError struct

func NewHeaderError added in v0.5.26

func NewHeaderError(
	header, err string, httpStatus int, errorCode *string,
) *HeaderError

NewHeaderError creates a new header error

func (*HeaderError) Error added in v0.5.26

func (h *HeaderError) Error() string

Error returns the header error as a string

func (*HeaderError) ErrorCode added in v0.5.28

func (h *HeaderError) ErrorCode() *string

ErrorCode returns the error code

func (*HeaderError) HTTPStatus added in v0.5.28

func (h *HeaderError) HTTPStatus() int

HTTPStatus returns the HTTP status

func (*HeaderError) Key added in v0.5.26

func (h *HeaderError) Key() string

Key returns the header name

type JSendBody added in v0.5.17

type JSendBody struct {
	Status string      `json:"status"`
	Data   interface{} `json:"data"`
}

JSendBody struct

type JSendErrorBody added in v0.6.0

type JSendErrorBody struct {
	JSendBody
	Message *string `json:"message,omitempty"`
	Code    *string `json:"code,omitempty"`
}

JSendErrorBody struct

func NewJSendErrorBody added in v0.5.17

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

NewJSendErrorBody creates a new JSend error response body

type JSendFailBody added in v0.6.0

type JSendFailBody struct {
	JSendBody
	Code *string `json:"code,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 {
	JSendBody
}

JSendSuccessBody struct

func NewJSendSuccessBody added in v0.5.17

func NewJSendSuccessBody(
	data interface{},
) *JSendSuccessBody

NewJSendSuccessBody creates a new JSend success response body

type RequestError added in v0.5.26

type RequestError interface {
	Key() string
	Error() string
	HTTPStatus() int
	ErrorCode() *string
}

RequestError struct

type Response added in v0.3.0

type Response interface {
	Body(mode *goflagsmode.Flag) interface{}
	HTTPStatus() int
}

Response interface

type SuccessResponse added in v0.6.0

type SuccessResponse struct {
	// contains filtered or unexported fields
}

SuccessResponse struct

func NewJSendSuccessResponse added in v0.5.0

func NewJSendSuccessResponse(
	data interface{},
	httpStatus int,
) *SuccessResponse

NewJSendSuccessResponse creates a new JSend success response

func NewSuccessResponse added in v0.5.0

func NewSuccessResponse(
	body interface{},
	httpStatus int,
) *SuccessResponse

NewSuccessResponse creates a new success response

func (*SuccessResponse) Body added in v0.6.0

func (r *SuccessResponse) Body(mode *goflagsmode.Flag) interface{}

Body returns the response body

func (*SuccessResponse) HTTPStatus added in v0.6.0

func (r *SuccessResponse) HTTPStatus() int

HTTPStatus returns the HTTP status

Jump to

Keyboard shortcuts

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