Documentation
¶
Overview ¶
Package client provides a TinyGo-compatible client for the HTTP host functions.
Index ¶
- Constants
- type Client
- func (c *Client) Delete(url string, headers Headers) (*Response, error)
- func (c *Client) Get(url string, headers Headers) (*Response, error)
- func (c *Client) Head(url string, headers Headers) (*Response, error)
- func (c *Client) Options(url string, headers Headers) (*Response, error)
- func (c *Client) Patch(url string, headers Headers, body string) (*Response, error)
- func (c *Client) Post(url string, headers Headers, body string) (*Response, error)
- func (c *Client) Put(url string, headers Headers, body string) (*Response, error)
- func (c *Client) Request(method uint32, url string, headers Headers, body string) (*Response, error)
- type HTTPError
- type Headers
- type Response
Constants ¶
View Source
const ( MethodGet uint32 = 0 MethodPost uint32 = 1 MethodPut uint32 = 2 MethodDelete uint32 = 3 MethodHead uint32 = 4 MethodOptions uint32 = 5 MethodPatch uint32 = 6 )
HTTP request method constants
View Source
const ( StatusSuccess uint32 = 0 StatusInvalidURL uint32 = 1 StatusNetworkError uint32 = 2 StatusTimeout uint32 = 3 StatusNotAllowed uint32 = 4 StatusTooLarge uint32 = 5 StatusBadInput uint32 = 6 StatusMemoryError uint32 = 7 )
Result codes
View Source
const ( DefaultHeadersBufferSize = 8 * 1024 // 8KB for headers DefaultBodyBufferSize = 256 * 1024 // 256KB for body )
Default buffer sizes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// HeadersBufferSize is the size of the buffer for response headers
HeadersBufferSize uint32
// BodyBufferSize is the size of the buffer for response body
BodyBufferSize uint32
}
Client is a HTTP client for making requests using the host functions
func NewClient ¶
func NewClient() *Client
NewClient creates a new HTTP client with default buffer sizes
type Headers ¶
Headers represents HTTP headers as a map
func ParseHeaders ¶
ParseHeaders parses a header string into a Headers map
Click to show internal directories.
Click to hide internal directories.