Documentation
¶
Overview ¶
Package utils offers utility functions for http requests, pagination, and filtering
Index ¶
- Constants
- func GetPageOfSlice(slice []string, page, perPage, maxPerPage int) ([]string, error)
- func GetPagingAttr(total, page, perPage, maxPerPage int) (int, int, error)
- func HTTPDoAuth(req *http.Request, ticket *obtainer.Client) (*http.Response, error)
- func HTTPRequest(method string, url string, headers map[string][]string, body io.Reader, ...) (*http.Response, error)
- func MatchObject(object interface{}, path []string, op string, value string) (bool, error)
- func ParsePagingParams(page, perPage string, maxPerPage int) (int, int, error)
- func ValidatePagingParams(page, perPage, maxPerPage int) error
Constants ¶
View Source
const ( GetParamPage = "page" GetParamPerPage = "per_page" )
View Source
const ( FOpEquals = "equals" FOpPrefix = "prefix" FOpSuffix = "suffix" FOpContains = "contains" )
Variables ¶
This section is empty.
Functions ¶
func GetPageOfSlice ¶
Returns a 'slice' of the given slice based on the requested 'page'
func GetPagingAttr ¶
Returns offset and limit representing a subset of the given slice total size
based on the requested 'page'
func HTTPDoAuth ¶
Send an HTTP request with X-Auth-Token entity-header.
Ticket is renewed once in case of failure.
func HTTPRequest ¶
func HTTPRequest(method string, url string, headers map[string][]string, body io.Reader, ticket *obtainer.Client) (*http.Response, error)
Constructs and submits an HTTP request and returns the response
func MatchObject ¶
func ParsePagingParams ¶
Parses string paging parameters to integers
func ValidatePagingParams ¶
Validates paging parameters
Types ¶
This section is empty.