response

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 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 Entity

type Entity[T any] struct {
	// contains filtered or unexported fields
}

func NewEntity

func NewEntity[T any](status int, data T, headers map[string]string) Entity[T]

func (Entity[T]) Headers

func (e Entity[T]) Headers() map[string]string

func (Entity[T]) Status

func (e Entity[T]) Status() int

func (Entity[T]) ToResponse

func (e Entity[T]) ToResponse() any

type Response

type Response[T any] struct {
	Success       bool `json:"success"`
	Data          T    `json:"data,omitempty"`
	Page          *int `json:"page,omitempty"`
	Size          *int `json:"size,omitempty"`
	TotalElements *int `json:"totalElements,omitempty"`
	TotalPages    *int `json:"totalPages,omitempty"`

	// Error fields
	Message          string                  `json:"message,omitempty"`
	ValidationErrors []validation.FieldError `json:"validationErrors,omitempty"`
}

func Error

func Error(msg string, fieldErrs ...validation.FieldError) Response[any]

func Success

func Success(data any) Response[any]

type Responser

type Responser interface {
	ToResponse() any
}

type Stature

type Stature interface {
	Status() int
}

Jump to

Keyboard shortcuts

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