Documentation
¶
Index ¶
- Constants
- func BuildBaseURL(c echo.Context) string
- func ExtraParams(c echo.Context) url.Values
- func Paginate(total int, p PaginationParams, baseURL string, extra url.Values) (next *string, previous *string)
- func ResolveOrgFromRequest(c echo.Context) string
- func ResolveSpaceSlugFromRequest(c echo.Context) (string, error)
- func SlicePage(total int, p PaginationParams) (start, end int)
- type PaginatedResponse
- type PaginationParams
Constants ¶
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
BuildBaseURL constructs the full URL (scheme + host + path) from the request.
func ExtraParams ¶ added in v0.0.2
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 ¶
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 ¶
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
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.