fetch

package
v0.0.0-...-659b40f Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeFormData

func EncodeFormData(value sobek.Value) (io.Reader, string, error)

EncodeFormData encodes a FormData object.

func Fetch

func Fetch(client Client) modules.ModuleFunc

Fetch the global fetch() method starts the process of fetching a resource from the network, returning a promise which is fulfilled once the response is available. https://developer.mozilla.org/en-US/docs/Web/API/fetch

func InitRequest

func InitRequest(rt *sobek.Runtime, url string, value sobek.Value) *http.Request

InitRequest builds a http.Request from the RequestInit option

func NewClient

func NewClient() *http.Client

NewClient return the http.Client implementation

func NewHeader

func NewHeader(rt *sobek.Runtime, src http.Header) sobek.Value

NewHeader creates a new Headers.

func NewRequest

func NewRequest(rt *sobek.Runtime, req *http.Request) sobek.Value

NewRequest returns a new js Request

func NewResponse

func NewResponse(rt *sobek.Runtime, res *http.Response) sobek.Value

NewResponse returns a new js Response

func NormalizeHeaderName

func NormalizeHeaderName(name string) string

NormalizeHeaderName normalizes a header name.

func NormalizeHeaderValue

func NormalizeHeaderValue(value string) string

NormalizeHeaderValue LF(0x0A) CR(0x0D) TAB(0x09) SPACE(0x20)

func ToHeader

func ToHeader(value sobek.Value) (http.Header, bool)

ToHeader converts a value to a http.Header.

func ToRequest

func ToRequest(rt *sobek.Runtime, value sobek.Value) (*http.Request, bool)

ToRequest converts a js Request object to an http.Request

func ToResponse

func ToResponse(value sobek.Value) (*http.Response, bool)

ToResponse converts a js Response object to an http.Response

Types

type Client

type Client interface {
	// Do sends an HTTP request and returns an HTTP response, following
	// policy (such as redirects, cookies, auth) as configured on the
	// client.
	Do(*http.Request) (*http.Response, error)
}

Client http client interface

type CookieJar

type CookieJar interface {
	http.CookieJar

	// RemoveCookie delete the cookies for the given URL.
	RemoveCookie(u *pkgurl.URL)
}

CookieJar manages storage and use of cookies in HTTP requests. Implementations of CookieJar must be safe for concurrent use by multiple goroutines.

func NewCookieJar

func NewCookieJar() CookieJar

NewCookieJar returns a new CookieJar that will store cookies in in-memory.

type CookieJarModule

type CookieJarModule struct{ CookieJar }

CookieJarModule manages storage and use of cookies in HTTP requests.

func (*CookieJarModule) Instantiate

func (c *CookieJarModule) Instantiate(rt *sobek.Runtime) (sobek.Value, error)

type FormData

type FormData struct{}

FormData provides a way to construct a set of key/value pairs representing form fields and their values. which can be sent using the http() method and encoding type were set to "multipart/form-data". https://developer.mozilla.org/en-US/docs/Web/API/FormData

func (*FormData) Instantiate

func (f *FormData) Instantiate(rt *sobek.Runtime) (sobek.Value, error)
type Header map[string][]string

type Headers

type Headers struct{}

Headers allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing headers from the list of the request's headers. https://developer.mozilla.org/en-US/docs/Web/API/Headers

func (*Headers) Instantiate

func (h *Headers) Instantiate(rt *sobek.Runtime) (sobek.Value, error)

type Request

type Request struct{}

Request interface of the Fetch API represents a resource request. https://developer.mozilla.org/en-US/docs/Web/API/Request/Request

func (*Request) Instantiate

func (r *Request) Instantiate(rt *sobek.Runtime) (sobek.Value, error)

type Response

type Response struct{}

Response represents the response to a request. https://developer.mozilla.org/en-US/docs/Web/API/Response

func (*Response) Instantiate

func (r *Response) Instantiate(rt *sobek.Runtime) (sobek.Value, error)

Jump to

Keyboard shortcuts

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