client

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2023 License: MIT Imports: 11 Imported by: 0

README

	c, _ := client.New()
	r := c.Get("https://www.google.com", nil, nil, 0)
	fmt.Println("SAMPLE HTML HEADER", r.Response)
	html, _ := r.Html()
	fmt.Println("SAMPLE HTML FIRST 64 CHARS", html[:64])

Documentation

Index

Constants

View Source
const TIMEOUT = 30000

TIMEOUT - default timeout

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Client *http.Client

	JSON bool
	// contains filtered or unexported fields
}

Client - initiated client instance

func New

func New() (Client, error)

New - creates an returns http client

func NewHTTP2

func NewHTTP2() (Client, error)

NewHTTP2 - creates and returns http/2 client

func (Client) Delete

func (c Client) Delete(ctx context.Context, url string, data []byte, hdr map[string]string) Res

Delete - http call using delete method, timeout in milli

func (Client) Get

func (c Client) Get(ctx context.Context, url string, data []byte, hdr map[string]string) Res

Get - http call using get method, timeout in milli

func (Client) Patch added in v0.0.6

func (c Client) Patch(ctx context.Context, url string, data []byte, hdr map[string]string) Res

Patch - http call using patch method, timeout in milli

func (Client) Post

func (c Client) Post(ctx context.Context, url string, data []byte, hdr map[string]string) Res

Post - http call using post method, timeout in milli

func (Client) Put

func (c Client) Put(ctx context.Context, url string, data []byte, hdr map[string]string) Res

Put - http call using put method, timeout in milli

func (*Client) SetJSON added in v0.0.4

func (c *Client) SetJSON(enabled bool)

SetJSON - changes the default JSON true to false - HTML content

func (*Client) SetLogger

func (c *Client) SetLogger(logtype string)

SetLogger - changes the logger mode

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout int)

SetTimeout - changes the default timeout set on code

type Res

type Res struct {
	Response http.Response
	Error    error

	HTML string
	JSON json.RawMessage
	// contains filtered or unexported fields
}

Res - response instance from http call

func (*Res) HTMLparse added in v0.0.4

func (r *Res) HTMLparse()

HTMLparse - method to return the html content of response

func (*Res) JSONparse added in v0.0.4

func (r *Res) JSONparse()

JSONparse - method to return the json content of response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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