common

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

func CallAPI

func CallAPI(cfg Configuration, request *http.Request) (*http.Response, error)

callAPI do the request.

func Decode

func Decode(v interface{}, b []byte, contentType string) (err error)

func MultipartDecode

func MultipartDecode(b []byte, v interface{}, boundary string) (err error)

func MultipartEncode

func MultipartEncode(v interface{}, body *bytes.Buffer) (string, error)

func ParameterToString

func ParameterToString(obj interface{}, collectionFormat string) string

ParameterToString convert interface{} parameters to string, using a delimiter if format is provided.

func PrepareRequest

func PrepareRequest(
	ctx context.Context,
	cfg Configuration,
	path string, method string,
	postBody interface{},
	headerParams map[string]string,
	queryParams url.Values,
	formParams url.Values,
	formFileName string,
	fileName string,
	fileBytes []byte) (localVarRequest *http.Request, err error)

prepareRequest build the request

func ReportError

func ReportError(format string, a ...interface{}) error

Prevent trying to import "fmt"

func SelectHeaderAccept

func SelectHeaderAccept(accepts []string) string

SelectHeaderAccept join all accept types and return

func TypeCheckParameter

func TypeCheckParameter(obj interface{}, expected string, name string) error

Verify optional parameters are of the correct type.

Types

type Configuration

type Configuration interface {
	BasePath() string
	Host() string
	UserAgent() string
	DefaultHeader() map[string]string
	HTTPClient() *http.Client
}

Jump to

Keyboard shortcuts

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