response

package
v0.10.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ErrInvalidFieldValueType = "invalid field value type, expected: '%s'"
)

Variables

View Source
var (
	ErrNilResponse      = errors.New("response cannot be nil")
	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  Status  `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

Parameters:

  • message: The error message
  • code: The error code

Returns:

  • *BaseJSendErrorBody: The base JSend error body

type BaseJSendFailBody added in v0.9.7

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

Parameters:

  • code: The error code

Returns:

  • *BaseJSendFailBody: The base JSend fail body

type BaseJSendSuccessBody added in v0.9.7

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

BaseJSendSuccessBody struct

func NewBaseJSendSuccessBody added in v0.9.5

func NewBaseJSendSuccessBody() *BaseJSendSuccessBody

NewBaseJSendSuccessBody creates a new base JSend success response body

Returns:

  • *BaseJSendSuccessBody: The base JSend success 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

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 {
	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

Parameters:

  • data: The data
  • message: The error message
  • code: The error code

Returns:

  • *JSendErrorBody: The JSend error 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

Parameters:

  • data: The data
  • code: The error code

Returns:

  • *JSendFailBody: The JSend fail 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

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(
	data interface{},
	message string,
	debugMessage string,
	code *string,
	httpStatus int,
) Response

NewJSendErrorDebugResponse creates a new JSend error response with debug information

Parameters:

  • data: The data
  • 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

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

NewJSendErrorResponse creates a new JSend error response

Parameters:

  • data: The data
  • message: The error message
  • code: The error code
  • httpStatus: The HTTP status code

Returns:

  • Response: The response

func NewJSendFailResponse added in v0.5.0

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

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

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

NewJSendSuccessResponse creates a new JSend success response

Parameters:

  • data: The data
  • httpStatus: The HTTP status code

Returns:

  • Response: The response

type Status added in v0.10.0

type Status string

Status is the response body status

const (
	// StatusSuccess indicates a successful response
	StatusSuccess Status = "success"

	// StatusFail indicates a failed response due to client error
	StatusFail Status = "fail"

	// StatusError indicates an error response due to server error
	StatusError Status = "error"
)

Jump to

Keyboard shortcuts

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