httpx

package
v0.0.0-...-f877a04 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package httpx contains HTTP extensions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GET

func GET(ctx context.Context, URL string) ([]byte, error)

GET performs a GET request and returns the body.

func GETWithBaseURL

func GETWithBaseURL(ctx context.Context, baseURL, path string) ([]byte, error)

GETWithBaseURL is like GET but with baseURL and path.

func POST

func POST(ctx context.Context, URL, contentType string, body []byte) ([]byte, error)

POST performs a POST request and returns the body.

func POSTWithBaseURL

func POSTWithBaseURL(ctx context.Context, baseURL, path, contentType string, body []byte) ([]byte, error)

POSTWithBaseURL performs a POST with a baseURL.

Types

type Request

type Request struct {
	// Ctx is the mandatory request context.
	Ctx context.Context

	// Method is the mandatory request method.
	Method string

	// URL is the mandatory request URL.
	URL string

	// ContentType is the optional content type.
	ContentType string

	// UserAgent is the optional user agent.
	UserAgent string

	// Body is the optional request body.
	Body []byte

	// NoFailOnError controls whether an HTTP failure causes
	// the Perform function to fail or not.
	NoFailOnError bool

	// SOCKS5ProxyPort is the optional SOCKS5 proxy port to use. The
	// default value (zero) means no proxy is used.
	SOCKS5ProxyPort int
}

Request is an HTTP request.

func (Request) Perform

func (r Request) Perform() (*Response, error)

Perform performs an HTTP request and returns the response.

type Response

type Response struct {
	// StatusCode is the HTTP status code.
	StatusCode int

	// ContentType is the optional content type.
	ContentType string

	// Body is the optional response body.
	Body []byte
}

Response is an HTTP response

Jump to

Keyboard shortcuts

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