dispatchhttp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = &Client{Client: http.DefaultClient}

DefaultClient is the default client.

Functions

This section is empty.

Types

type Client

type Client struct{ Client *http.Client }

Client wraps an http.Client to accept Request instances and return Response instances.

func (*Client) Do

func (c *Client) Do(ctx context.Context, r *Request) (*Response, error)

Do makes a HTTP Request and returns its Response.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) (*Response, error)

Get makes an HTTP GET request to the specified URL and returns its Response.

type Request

type Request struct {
	Method string
	URL    string
	Header http.Header
	Body   []byte
}

Request is an HTTP request.

func (*Request) MarshalJSON

func (r *Request) MarshalJSON() ([]byte, error)

func (*Request) UnmarshalJSON

func (r *Request) UnmarshalJSON(b []byte) error

type Response

type Response struct {
	StatusCode int
	Header     http.Header
	Body       []byte
}

Response is an HTTP response.

func FromResponse

func FromResponse(r *http.Response) (*Response, error)

FromResponse creates a Response from an http.Response.

The http.Response.Body is consumed and closed by this operation.

func Get

func Get(ctx context.Context, url string) (*Response, error)

Get makes an HTTP GET request to the specified URL and returns its Response.

func (*Response) MarshalJSON

func (r *Response) MarshalJSON() ([]byte, error)

func (*Response) Status

func (r *Response) Status() dispatchproto.Status

Status is the status for the response.

func (*Response) UnmarshalJSON

func (r *Response) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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