fetch

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 7 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 is an HTTP client.

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient returns new Client

func (*Client) Do

func (c *Client) Do(req *Request, init *RequestInit) (*http.Response, error)

Do sends an HTTP request and returns an HTTP response

func (*Client) HTTPClient

func (c *Client) HTTPClient(redirect RedirectMode) *http.Client

HTTPClient returns *http.Client.

type ClientOption

type ClientOption func(*Client)

ClientOption is a type that represents an optional function.

func WithBinding

func WithBinding(bind js.Value) ClientOption

WithBinding changes the objects that Fetch API belongs to. This is useful for service bindings, mTLS, etc.

type RedirectMode

type RedirectMode string

RedirectMode represents the redirect mode of a fetch() request.

var (
	RedirectModeFollow RedirectMode = "follow"
	RedirectModeError  RedirectMode = "error"
	RedirectModeManual RedirectMode = "manual"
)

func (RedirectMode) IsValid

func (mode RedirectMode) IsValid() bool

func (RedirectMode) String

func (mode RedirectMode) String() string

type Request

type Request struct {
	*http.Request
}

Request represents an HTTP request and is part of the Fetch API. Docs: https://developers.cloudflare.com/workers/runtime-apis/request/

func NewRequest

func NewRequest(ctx context.Context, method string, url string, body io.Reader) (*Request, error)

NewRequest returns new Request given a method, URL, and optional body

type RequestInit

type RequestInit struct {
	CF       *RequestInitCF
	Redirect RedirectMode
}

RequestInit represents the options passed to a fetch() request.

func (*RequestInit) ToJS

func (init *RequestInit) ToJS() js.Value

ToJS converts RequestInit to JS object.

type RequestInitCF

type RequestInitCF struct {
}

RequestInitCF represents the Cloudflare-specific options passed to a fetch() request.

Jump to

Keyboard shortcuts

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