apiclient

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 10 Imported by: 0

README

-apiClient-go

Standardised API Client package

-apiClient-go is part of the kiss-my-package set used by apps like FaceMasq, PaperBag, Celestial, Executrix, and more

Documentation

Index

Constants

View Source
const ErrorThreshold = 300

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	Engine       http.Client
	LooseCookies []*http.Cookie
}

func Prepare

func Prepare() *APIClient

Prepare sets-up the client used in Do().

func (*APIClient) ClearLooseCookies

func (client *APIClient) ClearLooseCookies()

func (*APIClient) Do

func (client *APIClient) Do(ctx context.Context, request *Request) (*Response, error)

Do creates a http.Request from an Request and executes the request.

type Auth

type Auth struct {
	Type     string
	Username string
	Password string
}

Auth is a struct used to store the parameters of the request authentication values.

type BodyParams

type BodyParams map[string]string

BodyParams is a map of strings, with a string key, used to store the parameters of the request body.

type Headers

type Headers map[string]string

Headers is a map of strings, with a string key, used to store the parameters of the request headers.

type Request

type Request struct {
	URL             string
	Method          string
	EndPoint        string
	EndPointParams  URLParams
	DynamicEndPoint bool
	Headers         Headers
	Path            []string
	Query           url.Values
	Body            BodyParams
	BodyJSON        io.Reader
	Auth            Auth
	BodyText        string
	Cookies         []*http.Cookie
}

Request is a struct used to store the collective data of the API/Web Request used by Do() and Build().

type Response

type Response struct {
	*http.Response
	Body    string
	Cookies string
}

type URLParams

type URLParams map[string]string

URLParams is a map of strings, with a string key, used to store the parameters of the request url.

Jump to

Keyboard shortcuts

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