Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, res PagingResponse) error
WriteResponse writes to http.ResponseWriter the pagination values determined by PagingResponse.
Types ¶
type PagingLinks ¶
type PagingLinks struct { // First contains the URL where clients should query the first page of elements. First *url.URL // Previous contains the URL where clients should query the first page of elements. Previous *url.URL // Next contains the URL where clients should query the first page of elements. Next *url.URL // Last contains the URL where clients should query the first page of elements. Last *url.URL }
PagingLinks contains a set of URLs to help with pagination.
func (PagingLinks) ToLinkHeaders ¶
func (p PagingLinks) ToLinkHeaders() []string
ToLinkHeaders converts the links in PagingLinks to an array of links to use in the "Link" HTTP header.
type PagingRequest ¶
type PagingRequest struct { // Page is the page that should be shown. When using ReadRequest, this value defaults to 1. Page uint64 // PageSize contains the amount of elements that a Page will include. When using ReadRequest, this value defaults to 30. PageSize uint64 }
PagingRequest is used to describe pagination values from incoming requests.
func ReadRequest ¶
func ReadRequest(r *http.Request) PagingRequest
ReadRequest reads the PagingRequest from a http.Request.
type PagingResponse ¶
type PagingResponse struct { // BaseURL contains the base url that should be used to interact with the desired API list method that supports pagination. // If BaseURL contains query params for page and page_size, those values will be overwritten. BaseURL *url.URL // Page contains the page that was requested. Page uint64 // PageSize contains the amount of elements that were requested for this Page. PageSize uint64 // Count contains the amount of elements that were retrieved for this Page. Count uint64 // TotalCount contains the elements available, usually used to calculate the amount of pages available. TotalCount uint64 }
PagingResponse contains the values that should be added to an HTTP response.
func (PagingResponse) ToPagingLinks ¶
func (r PagingResponse) ToPagingLinks() PagingLinks
ToPagingLinks converts the current PagingResponse to a group of links described by PagingLinks.
Click to show internal directories.
Click to hide internal directories.