response

package
v1.22.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(w http.ResponseWriter, message string)

func DoRawResponse

func DoRawResponse(w http.ResponseWriter, status int, data interface{}, headers map[string]string)

func Error

func Error(w http.ResponseWriter, err error)

func NotFound

func NotFound(w http.ResponseWriter, message string)

func OK

func OK(w http.ResponseWriter, data interface{})

func ServerError

func ServerError(w http.ResponseWriter, err error)

Types

type Named

type Named interface {
	GetName() string
}

type Page

type Page struct {
	List  interface{} `json:"list"`
	Total int64       `json:"total"`
	Page  int64       `json:"page,omitempty"`
	Size  int64       `json:"size,omitempty"`
}

func NewPageData

func NewPageData(list interface{}, page, size int, filterfn PageFilterFunc, sortfn PageSortFunc) Page

type PageFilterFunc

type PageFilterFunc func(i int) bool

type PageSortFunc

type PageSortFunc func(i, j int) bool

type Response

type Response struct {
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
	Error   interface{} `json:"error,omitempty"`
}

type SortAndSearchAble

type SortAndSearchAble interface {
	GetName() string
	GetCreationTimestamp() metav1.Time
}

type StatusError

type StatusError struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

func NewError

func NewError(status int, message string) *StatusError

func (StatusError) Error

func (e StatusError) Error() string

type TypedFilterFun

type TypedFilterFun[T any] func(item T) bool

type TypedPage

type TypedPage[T any] struct {
	Total       int64
	List        []T
	CurrentPage int64
	CurrentSize int64
}

func NewTypedPage

func NewTypedPage[T any](list []T, page, size int, pickfun func(item T) bool, sortfun func(a, b T) bool) TypedPage[T]

type TypedSortFun

type TypedSortFun[T any] func(a, b T) bool

Jump to

Keyboard shortcuts

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