response

package
v0.8.30 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IError

type IError interface {
	error
	Code() string
}

type Pagination added in v0.8.10

type Pagination struct {
	Cursor interface{} `json:"cursor,omitempty"`
	Total  *int64      `json:"total,omitempty"`
}

Pagination contains data related to pagination for a request

type Response

type Response[T any, E any] struct {
	Error      *ResponseError[E] `json:"error,omitempty"`
	Data       T                 `json:"data,omitempty"`
	Pagination *Pagination       `json:"pagination,omitempty"`
}

func Error

func Error(err IError) Response[*int, *int]

func ErrorExplicit

func ErrorExplicit[E any](code string, message string, data E) Response[*int, E]

func ErrorWithData

func ErrorWithData[E any](err IError, data E) Response[*int, E]

func Success

func Success() Response[*int, *int]

func SuccessWithData

func SuccessWithData[T any](data T, pagination ...Pagination) Response[T, *int]

type ResponseError

type ResponseError[E any] struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    E      `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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