httpclient

package module
v1.1.3 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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides methods for making REST requests.

func New

func New(opts ...Option) *Client

New creates a new Client instance.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, request *Request) (Response, error)

Delete execute a http DELETE method with application/json headers.

func (*Client) Get

func (c *Client) Get(ctx context.Context, request *Request) (Response, error)

Get execute a http GET method.

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, request *Request) (rst Response, err error)

Patch execute a http PATCH method with application/json headers.

func (*Client) Post

func (c *Client) Post(ctx context.Context, request *Request) (Response, error)

Post execute a http POST method with application/json headers.

func (*Client) PostForm

func (c *Client) PostForm(ctx context.Context, request *Request) (Response, error)

PostForm execute a http POST method with x-www-form-urlencoded headers.

func (*Client) Put

func (c *Client) Put(ctx context.Context, request *Request) (rst Response, err error)

Put execute a http PUT method with application/json headers.

type Headers added in v1.1.3

type Headers map[string]string

Headers is a map containing the relation key=value of the headers used on the http rest request.

type Option

type Option func(*Client)

Option is a type to set HTTP Client options.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout instructs the HTTP Client to cancel any requests that exceeds the given timeout.

type PathParams added in v1.1.3

type PathParams map[string]string

PathParams is a map containing the relation key=value of the path params used on the http rest request. It will be used to replace values given in Path parameter.

type QueryParams added in v1.1.3

type QueryParams map[string]string

QueryParams is a map containing the relation key=value of the query params used on the http rest request.

type Request added in v1.1.3

type Request struct {
	Host        string
	Path        string
	Body        []byte
	Headers     Headers
	QueryParams QueryParams
	PathParams  PathParams
}

Request are the params used to build a new http rest request.

type Response added in v1.1.3

type Response struct {
	StatusCode int
	Body       []byte
}

Response encapsulates data returned from the client HTTP request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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