Documentation ¶
Overview ¶
Package http is a client package for WASM functions running within a Tarmac server.
This package provides user-friendly HTTP client functions that can interact with external HTTP services. Guest WASM functions running inside Tarmac can import and call this HTTP client.
Index ¶
- type Client
- func (h *Client) Delete(url string) (Response, error)
- func (h *Client) Do(method string, headers map[string]string, url string, insecure bool, ...) (Response, error)
- func (h *Client) Get(url string) (Response, error)
- func (h *Client) Post(url string, payload []byte) (Response, error)
- func (h *Client) Put(url string, payload []byte) (Response, error)
- type Config
- type Response
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 an interface to make outbound HTTP calls.
func (*Client) Do ¶
func (h *Client) Do(method string, headers map[string]string, url string, insecure bool, payload []byte) (Response, error)
Do will perform HTTP requests using the specified parameters. Valid Methods are GET, POST, PUT, and DELETE.
type Config ¶
type Config struct { // Namespace controls the function namespace to use for host callbacks. The default value is "default" which is the global namespace. // Users can provide an alternative namespace by specifying this field. Namespace string // HostCall is used internally for host callbacks. This is mainly here for testing. HostCall func(string, string, string, []byte) ([]byte, error) }
Config provides users with the ability to specify namespaces, function handlers and other key information required to execute the function.
type Response ¶
type Response struct { // StatusCode is the HTTP status code returned by the Client. StatusCode int // Headers are the returned HTTP headers from the server response. Headers map[string]string // Body is the returned HTTP body from the server response. Body []byte }
Response is returned from successful client calls.
Click to show internal directories.
Click to hide internal directories.