clevergo / pagination

:bookmark_tabs: Restful API Pagination

Home Page:https://clevergo.tech

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pagination

Build Status Coverage Status Go.Dev reference Go Report Card Release Downloads

Usage

import "clevergo.tech/pagination"
// query entities from database.
func query(limit, offset int64) (total int64, es []entity, err error) {
    return
}

func index(w http.ResponseWriter, req *http.Request) {
    p := pagination.NewFromRequest(req)
    p.Total, p.Items, _ = query(p.Limit, p.Offset())
    data, _ := json.Marshal(p)
    w.Write(data)
}

About

:bookmark_tabs: Restful API Pagination

https://clevergo.tech

License:MIT License


Languages

Language:Go 100.0%