response

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 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)

type ManyResponse

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

func NewManyResponse

func NewManyResponse[T any](models []T) (int, ManyResponse[T])

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 SingleResponse

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

func NewSingleResponse

func NewSingleResponse[T any](model T) (int, SingleResponse[T])

func NewSingleResponseCreated added in v0.8.0

func NewSingleResponseCreated[T any](model T) (int, SingleResponse[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