httptools

package
v0.0.0-...-a4179b6 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ApplicationJson stands for application/json.
	ApplicationJson = "application/json"
	// ContentType is the header key for Content-Type.
	ContentType = "Content-Type"
	// JsonContentType is the content type for JSON.
	JsonContentType = "application/json; charset=utf-8"
)

Variables

View Source
var ErrGetWithBody = errors.New("HTTP GET should not have body")

ErrGetWithBody indicates that GET request with body.

Functions

func Do

func Do(ctx context.Context, method, url string, data interface{}, opentrace bool) (*http.Response, error)

Do sends an HTTP request with the given arguments and returns an HTTP response, data is automatically marshal into a *httpRequest.

func DoRequest

func DoRequest(r *http.Request) (*http.Response, error)

DoRequest sends an HTTP request and returns an HTTP response.

func DoRequestWithCustomClient

func DoRequestWithCustomClient(cli *http.Client, r *http.Request) (*http.Response, error)

DoRequestWithCustomClient sends an HTTP request and returns an HTTP response.

func DoWithCustomClient

func DoWithCustomClient(ctx context.Context, cli *http.Client, method, url string, data interface{}, opentrace bool) (*http.Response, error)

DoWithCustomClient sends an HTTP request with the given arguments and returns an HTTP response, data is automatically marshal into a *httpRequest.

func Parse

func Parse(resp *http.Response, val interface{}) error

Parse parses the response.

func ParseHeaders

func ParseHeaders(resp *http.Response, val interface{}) error

ParseHeaders parses the rsponse headers.

func ParseJsonBody

func ParseJsonBody(resp *http.Response, val interface{}) error

ParseJsonBody parses the rsponse body, which should be in json content type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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