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: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLimit = 20

DefaultLimit is the default number of items per page for most endpoints

Variables

This section is empty.

Functions

func BuildBaseURL added in v0.0.2

func BuildBaseURL(c echo.Context) string

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

func ExtraParams added in v0.0.2

func ExtraParams(c echo.Context) url.Values

ExtraParams clones the request's query parameters, stripping limit and offset so they can be passed to Paginate for building next/previous URLs.

func Paginate added in v0.0.2

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 ResolveOrgFromRequest

func ResolveOrgFromRequest(c echo.Context) string

ResolveOrgFromRequest extracts organization from hostname (like spacedf.localhost) or from X-Organization header with header taking priority. Format: {org_slug}.{domain} where domain is configured in settings

func ResolveSpaceSlugFromRequest

func ResolveSpaceSlugFromRequest(c echo.Context) (string, error)

ResolveSpaceSlugFromRequest extracts space_slug from X-Space header. Returns an error if the header is missing.

func SlicePage added in v0.0.2

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

SlicePage returns the slice of items for the current page.

Types

type PaginatedResponse added in v0.0.2

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 added in v0.0.2

type PaginationParams struct {
	Limit  int
	Offset int
}

PaginationParams holds parsed limit and offset values.

func ParsePagination added in v0.0.2

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

ParsePagination extracts limit and offset from the query parameters, applying defaults and bounds.

Jump to

Keyboard shortcuts

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