Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PagiRequest ¶
type PagiRequest struct { // Page is a pointer to int // Page is a query parameter for page number // Page is validated to be greater than 0 Page *int `query:"page" validate:"omitempty,gt=0"` // Limit is a pointer to int // Limit is a query parameter for limit number of items per page // Limit is validated to be greater than 0 Limit *int `query:"limit" validate:"omitempty,gt=0"` }
PagiRequest is a struct for pagination request
func (*PagiRequest) Default ¶
func (r *PagiRequest) Default()
Default is a method to set default value for PagiRequest Default set Page to 1 if Page is nil or less than 1 Default set Limit to 10 if Limit is nil or less than 1
func (*PagiRequest) Offset ¶
func (r *PagiRequest) Offset() int
Offset is a method to calculate offset for pagination
func (*PagiRequest) TotalPage ¶
func (r *PagiRequest) TotalPage(total int64) int
TotalPage is a method to calculate total page for pagination
type PagiResponse ¶
type PagiResponse[T any] struct { Page int `json:"page"` Limit int `json:"limit"` Total int64 `json:"total"` FilteredTotal int64 `json:"filtered_total"` TotalPage int `json:"total_page"` List []T `json:"list"` }
PagiResponse is a struct for pagination response PagiResponse contains page number, limit, total items, filtered total items, total page, and list of items PagiResponse is a generic struct
Click to show internal directories.
Click to hide internal directories.