httpx

package
v0.0.0-...-6606c74 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Order

type Order int
const (
	ASC  Order = 1
	DESC Order = -1
)

func ParserOrder

func ParserOrder(val any) Order

func (Order) String

func (o Order) String() string

type Pageable

type Pageable interface {
	GetPageSize() int
	GetPageNum() int
	GetOffset() int
	SetTotal(int64)
	GetSorts() []SortItem
}

type Pagination

type Pagination struct {
	Size   int        `json:"size,omitempty"`
	Page   int        `json:"page,omitempty"`
	Total  int64      `json:"total,omitempty"`
	Offset int        `json:"-"`
	Sorts  []SortItem `json:"-"`
}

func PaginationFromQuery

func PaginationFromQuery(req *http.Request) *Pagination

func (*Pagination) GetOffset

func (p *Pagination) GetOffset() int

func (*Pagination) GetPageNum

func (p *Pagination) GetPageNum() int

func (*Pagination) GetPageSize

func (p *Pagination) GetPageSize() int

func (*Pagination) GetSorts

func (p *Pagination) GetSorts() []SortItem

func (*Pagination) SetTotal

func (p *Pagination) SetTotal(total int64)

type Response

type Response struct {
	Code    int    `json:"code"`
	Message string `json:"message,omitempty"`
	Error   string `json:"error,omitempty"`
	Data    any    `json:"data,omitempty"`
	Pagination
}

func NewResponse

func NewResponse(c int) *Response

func ResponseOK

func ResponseOK() *Response

func (*Response) WithData

func (r *Response) WithData(data any) *Response

func (*Response) WithError

func (r *Response) WithError(err string) *Response

func (*Response) WithMessage

func (r *Response) WithMessage(msg string) *Response

func (*Response) WithPagination

func (r *Response) WithPagination(pagination *Pagination) *Response

type SortItem

type SortItem struct {
	Field string
	Order Order
}

func (SortItem) Sql

func (i SortItem) Sql() string

Jump to

Keyboard shortcuts

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