common

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBaseURL

func BuildBaseURL(c echo.Context) string

BuildBaseURL constructs the full URL (scheme + host + path) from the request.

func Paginate

func Paginate(total int, p PaginationParams, baseURL string, extra url.Values) (next *string, previous *string)

Paginate takes a total count, pagination params, base URL built from the request, and optional

func SlicePage

func SlicePage(total int, p PaginationParams) (start, end int)

SlicePage returns the slice of items for the current page.

Types

type PaginatedResponse

type PaginatedResponse struct {
	Count    int         `json:"count"`
	Next     *string     `json:"next"`
	Previous *string     `json:"previous"`
	Results  interface{} `json:"results"`
}

PaginatedResponse represents a generic paginated API response.

type PaginationParams

type PaginationParams struct {
	Limit  int
	Offset int
}

PaginationParams holds parsed limit and offset values.

func ParsePagination

func ParsePagination(c echo.Context, defaultLimit int) PaginationParams

ParsePagination extracts limit and offset from query params with defaults.

Jump to

Keyboard shortcuts

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