api

package
v1.12.6 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// HTTPClient variable - is the client used to make HTTP calls in loli cli.
	// For more information: https://medium.com/@nate510/don-t-use-go-s-default-http-client-4804cb19f779
	HTTPClient = &http.Client{
		Timeout: time.Duration(consts.TimeoutInSeconds) * time.Second,
		Transport: &http.Transport{
			Proxy: http.ProxyFromEnvironment,
			DialContext: (&net.Dialer{
				Timeout:   30 * time.Second,
				KeepAlive: 30 * time.Second,
				DualStack: true,
			}).DialContext,
			ForceAttemptHTTP2:     true,
			MaxIdleConns:          100,
			IdleConnTimeout:       90 * time.Second,
			TLSHandshakeTimeout:   10 * time.Second,
			ExpectContinueTimeout: 1 * time.Second,
			TLSClientConfig: &tls.Config{
				InsecureSkipVerify: consts.InsecureSkipVerify,
			},
		},
	}
)

Functions

This section is empty.

Types

type Client

type Client struct {
	*http.Client        // HTTP Client pointer
	BaseURL      string // HTTP Request URL
	ContentType  string // HTTP Request Content Type
}

Client struct - is an http client that is configured for API.

func NewClient

func NewClient(baseURL string) (*Client, error)

NewClient returns a API client.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do performs an http.Request and optionally parses the response body into the given interface.

func (*Client) NewRequest

func (c *Client) NewRequest(method, url string, body io.Reader) (*http.Request, error)

NewRequest returns an http.Request with information for the API. For more information: https://golang.org/pkg/net/http/

Jump to

Keyboard shortcuts

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