Documentation ¶
Overview ¶
paginator imlementation for golang
Index ¶
Constants ¶
View Source
const ( DEFAULT_PAGE = 1 DEFAULT_PAGE_PARAM = "page" DEFAULT_PER_PAGE = 10 DEFAULT_PER_PAGE_PARAM = "limit" // context keys CONTEXT_ON_REQUEST_REQUEST = 1 )
Variables ¶
View Source
var (
DEBUG = true
)
Functions ¶
Types ¶
type Factory ¶
type Factory func(from ...interface{}) Paginator
Factory function that returns paging, from can be request of gorm dg
func NewFactory ¶
NewFactory returns function that produces instance of Paginator. options control the creation of Paginators. If you provide any compatible `froms` when calling factory, they will be passed to `From` method.
type Option ¶
Option for paginator factory
func DisablePerPage ¶
func DisablePerPage() Option
func PerPageParam ¶
OptPerPageParam sets per page param name on factory, if blank value given, it's disabled
type Paginator ¶
type Paginator interface { Count(int) Paginator GetCount() int Page(int) Paginator GetPage() int PerPage(int) Paginator GetPerPage() int // Normalize normalizes paginator (runs all options on it) Normalize() Paginator // return num of pages GetNumPages() int // read data from request, db From(...interface{}) Paginator FromDB(DB *gorm.DB, normalize ...bool) Paginator //FromJSON([]byte) Paginator FromRequest(request *http.Request, normalize ...bool) Paginator FromURLValues(values url.Values, normalize ...bool) Paginator // signal to be called when `From` with request is called or `FromRequest` OnRequest(signals.Receiver, ...string) PerPageParam(string) Paginator PageParam(string) Paginator GetLimitOffset(add ...bool) (int, int) // json marshal interface MarshalJSON() ([]byte, error) UpdateURLValues(values url.Values) Paginator }
Paginator interface
Click to show internal directories.
Click to hide internal directories.