response

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrResponse

type ErrResponse struct {
	// Code is the error code
	Code int `json:"code"`
	// Message is the error message
	Message string `json:"message"`
	// Validation errors
	Errors map[string]string `json:"errors,omitempty"`
}

ErrResponse is a generic error response

func NewErrResponse

func NewErrResponse(e error) (int, ErrResponse)

func NewErrResponseBadRequest

func NewErrResponseBadRequest(message string) (int, ErrResponse)

func NewErrResponseException added in v0.7.0

func NewErrResponseException(message string) (int, ErrResponse)

func NewErrResponseForbidden

func NewErrResponseForbidden(message string) (int, ErrResponse)

func NewErrResponseNotFound

func NewErrResponseNotFound(message string) (int, ErrResponse)

func NewErrResponseValidationErrors

func NewErrResponseValidationErrors(message string, errors map[string]string) (int, ErrResponse)

func (ErrResponse) HasErrorField added in v0.19.0

func (e ErrResponse) HasErrorField(errorField string) bool

func (ErrResponse) HasErrorFields added in v0.19.0

func (e ErrResponse) HasErrorFields(errorFields []string) bool

type ManyResponsePaginated added in v0.7.0

type ManyResponsePaginated[T any] struct {
	Data       []T `json:"data"`
	Pagination struct {
		Total int64 `json:"total"`
	} `json:"pagination"`
}

func NewManyResponsePaginated added in v0.7.0

func NewManyResponsePaginated[T any](models []T, total int64) (int, ManyResponsePaginated[T])

type Response added in v0.20.0

type Response[T any] struct {
	Data T `json:"data"`
}

func NewResponse added in v0.20.0

func NewResponse[T any](model T) (int, Response[T])

func NewResponseCreated added in v0.20.0

func NewResponseCreated[T any](model T) (int, Response[T])

type SuccessResponse

type SuccessResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func NewSuccessResponse

func NewSuccessResponse(message string) (int, SuccessResponse)

func NewSuccessResponseCreated

func NewSuccessResponseCreated(message string) (int, SuccessResponse)

Jump to

Keyboard shortcuts

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