utils

package
v3.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package utils offers utility functions for http requests, pagination, and filtering

Index

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

func GetPageOfSlice(slice []string, page, perPage, maxPerPage int) ([]string, error)

Returns a 'slice' of the given slice based on the requested 'page'

func GetPagingAttr

func GetPagingAttr(total, page, perPage, maxPerPage int) (int, int, error)

Returns offset and limit representing a subset of the given slice total size

based on the requested 'page'

func HTTPDoAuth

func HTTPDoAuth(req *http.Request, ticket *obtainer.Client) (*http.Response, error)

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 MatchObject(object interface{}, path []string, op string, value string) (bool, error)

func ParsePagingParams

func ParsePagingParams(page, perPage string, maxPerPage int) (int, int, error)

Parses string paging parameters to integers

func ValidatePagingParams

func ValidatePagingParams(page, perPage, maxPerPage int) error

Validates paging parameters

Types

This section is empty.

Jump to

Keyboard shortcuts

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