response

package
v0.0.0-...-d389d3b Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Message string `json:"message" example:"invalid id"`
	Field   string `json:"field,omitempty" example:"id"`
	Value   any    `json:"value,omitempty"`
}

func NewAPIError

func NewAPIError(message string) APIError

func NewAPIErrorWithField

func NewAPIErrorWithField(message string, field string, value any) APIError

func NewAPIErrorWithValue

func NewAPIErrorWithValue(message string, value any) APIError

type APIErrorResponse

type APIErrorResponse struct {
	Errors []APIError
}

type APIResponse

type APIResponse interface{}

func NewAPIErrorResponse

func NewAPIErrorResponse(errors []APIError) APIResponse

type APIResponseEnvelope

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

func NewEnvelope

func NewEnvelope(status int, options ...ResponseEnvelopeOption) *APIResponseEnvelope

func NewWithResponse

func NewWithResponse(status int, payload APIResponse) *APIResponseEnvelope

func (APIResponseEnvelope) Response

func (r APIResponseEnvelope) Response() APIResponse

func (APIResponseEnvelope) Status

func (r APIResponseEnvelope) Status() int

type PageableResponse

type PageableResponse[T any] struct {
	Content          []T
	Empty            bool
	Number           int
	NumberOfElements int
	TotalElements    int
	TotalPages       int
}

func NewPageableResponse

func NewPageableResponse[T any](
	content []T,
	empty bool,
	number int,
	numberOfElements int,
	totalElements int,
	totalPages int,
) *PageableResponse[T]

type ResponseEnvelopeOption

type ResponseEnvelopeOption func(envelop *APIResponseEnvelope)

func WithResponse

func WithResponse(response APIResponse) ResponseEnvelopeOption

Jump to

Keyboard shortcuts

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