http

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package http the http JS implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAsyncResponse added in v0.4.2

func NewAsyncResponse(vm *goja.Runtime, res *http.Response) goja.Value

NewAsyncResponse returns a new async Response

func NewReadableStream added in v0.4.2

func NewReadableStream(body io.ReadCloser, vm *goja.Runtime, bodyUsed *bool) *goja.Object

NewReadableStream ReadableStream API https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream

func NewResponse

func NewResponse(vm *goja.Runtime, res *http.Response) goja.Value

NewResponse returns a new Response

Types

type AbortController added in v0.4.2

type AbortController struct {
	Signal  *AbortSignal
	Aborted bool
	Reason  string
}

AbortController interface represents a controller object that allows you to abort one or more Web requests as and when desired. https://developer.mozilla.org/en-US/docs/Web/API/AbortController.

func (*AbortController) Abort added in v0.4.2

func (c *AbortController) Abort()

type AbortControllerConstructor added in v0.4.2

type AbortControllerConstructor struct{}

AbortControllerConstructor AbortController Constructor

func (*AbortControllerConstructor) Exports added in v0.4.2

func (*AbortControllerConstructor) Exports() any

Exports AbortController Constructor

func (*AbortControllerConstructor) Global added in v0.4.2

func (*AbortControllerConstructor) Global()

Global it is a global module

type AbortSignal added in v0.4.0

type AbortSignal struct {
	Aborted bool
	Reason  string
	// contains filtered or unexported fields
}

AbortSignal represents a signal object that allows you to communicate with http request and abort it. https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal

type AbortSignalModule added in v0.4.2

type AbortSignalModule struct{}

func (*AbortSignalModule) Exports added in v0.4.2

func (*AbortSignalModule) Exports() any

func (*AbortSignalModule) Global added in v0.4.2

func (*AbortSignalModule) Global()

type FetchModule added in v0.4.2

type FetchModule struct{}

FetchModule 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 (*FetchModule) Exports added in v0.4.2

func (*FetchModule) Exports() any

func (*FetchModule) Global added in v0.4.2

func (*FetchModule) Global()

type FileData

type FileData struct {
	Data     []byte
	Filename string
}

FileData wraps the file data and filename

type FormData

type FormData struct {
	// contains filtered or unexported fields
}

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". Implement the https://developer.mozilla.org/en-US/docs/Web/API/FormData

func (*FormData) Append

func (f *FormData) Append(name string, value any, filename string) (ret goja.Value)

Append method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.

func (*FormData) Delete

func (f *FormData) Delete(name string)

Delete method of the FormData interface deletes a key and its value(s) from a FormData object.

func (*FormData) Entries

func (f *FormData) Entries() any

Entries method returns an iterator which iterates through all key/value pairs contained in the FormData.

func (*FormData) Get

func (f *FormData) Get(name string) any

Get method of the FormData interface returns the first value associated with a given key from within a FormData object. If you expect multiple values and want all of them, use the getAll() method instead.

func (*FormData) GetAll

func (f *FormData) GetAll(name string) any

GetAll method of the FormData interface returns all the values associated with a given key from within a FormData object.

func (*FormData) Has

func (f *FormData) Has(name string) bool

Has method of the FormData interface returns whether a FormData object contains a certain key.

func (*FormData) Keys

func (f *FormData) Keys() any

Keys method returns an iterator which iterates through all keys contained in the FormData. The keys are strings.

func (*FormData) Set

func (f *FormData) Set(name string, value any, filename string)

Set method of the FormData interface sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.

func (*FormData) Values

func (f *FormData) Values() any

Values method returns an iterator which iterates through all values contained in the FormData.

type FormDataConstructor added in v0.4.0

type FormDataConstructor struct{}

FormDataConstructor FormData Constructor

func (*FormDataConstructor) Exports added in v0.4.0

func (*FormDataConstructor) Exports() any

Exports returns module instance

func (*FormDataConstructor) Global added in v0.4.0

func (*FormDataConstructor) Global()

Global it is a global module

type Http

type Http struct {
	// contains filtered or unexported fields
}

Http module for fetching resources (including across the network).

func (*Http) Delete added in v0.4.0

func (h *Http) Delete(call goja.FunctionCall, vm *goja.Runtime) goja.Value

Delete Make a HTTP DELETE request.

func (*Http) Get

func (h *Http) Get(call goja.FunctionCall, vm *goja.Runtime) goja.Value

Get Make a HTTP GET request.

func (*Http) Head

func (h *Http) Head(call goja.FunctionCall, vm *goja.Runtime) goja.Value

Head Make a HTTP HEAD request.

func (*Http) Patch added in v0.4.2

func (h *Http) Patch(call goja.FunctionCall, vm *goja.Runtime) goja.Value

Patch Make a HTTP PATCH request.

func (*Http) Post

func (h *Http) Post(call goja.FunctionCall, vm *goja.Runtime) goja.Value

Post Make a HTTP POST. Send POST with multipart: http.post(url, { body: new FormData({'bytes': new Uint8Array([0]).buffer}) }) Send POST with x-www-form-urlencoded: http.post(url, { body: new URLSearchParams({'key': 'foo', 'value': 'bar'}) }) Send POST with json: http.post(url, { body: {'key': 'foo'} })

func (*Http) Put added in v0.4.0

func (h *Http) Put(call goja.FunctionCall, vm *goja.Runtime) goja.Value

Put Make a HTTP PUT request.

func (*Http) Request

func (h *Http) Request(call goja.FunctionCall, vm *goja.Runtime) goja.Value

Request Make a HTTP request.

type Module

type Module struct{}

Module js module

func (*Module) Exports

func (*Module) Exports() any

Exports returns module instance

type URLSearchParams

type URLSearchParams struct {
	// contains filtered or unexported fields
}

The URLSearchParams defines utility methods to work with the query string of a URL, which can be sent using the http() method and encoding type were set to "application/x-www-form-url". Implement the https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams

func (*URLSearchParams) Append

func (u *URLSearchParams) Append(name, value string)

Append method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.

func (*URLSearchParams) Delete

func (u *URLSearchParams) Delete(name string)

Delete method of the URLSearchParams interface deletes the given search parameter and all its associated values, from the list of all search parameters.

func (*URLSearchParams) Entries

func (u *URLSearchParams) Entries() any

Entries method of the URLSearchParams interface returns an iterator allowing iteration through all key/value pairs contained in this object. The iterator returns key/value pairs in the same order as they appear in the query string. The key and value of each pair are string objects.

func (*URLSearchParams) ForEach

func (u *URLSearchParams) ForEach(call goja.FunctionCall, vm *goja.Runtime) (ret goja.Value)

ForEach method of the URLSearchParams interface allows iteration through all values contained in this object via a callback function.

func (*URLSearchParams) Get

func (u *URLSearchParams) Get(name string) any

Get method of the URLSearchParams interface returns the first value associated to the given search parameter.

func (*URLSearchParams) GetAll

func (u *URLSearchParams) GetAll(name string) []string

GetAll method of the URLSearchParams interface returns all the values associated with a given search parameter as an array.

func (*URLSearchParams) Has

func (u *URLSearchParams) Has(name string) bool

Has method of the URLSearchParams interface returns a boolean value that indicates whether a parameter with the specified name exists.

func (*URLSearchParams) Keys

func (u *URLSearchParams) Keys() []string

Keys method of the URLSearchParams interface returns an iterator allowing iteration through all keys contained in this object. The keys are string objects.

func (*URLSearchParams) Set

func (u *URLSearchParams) Set(name, value string)

Set method of the URLSearchParams interface sets the value associated with a given search parameter to the given value. If there were several matching values, this method deletes the others. If the search parameter doesn't exist, this method creates it.

func (*URLSearchParams) Sort

func (u *URLSearchParams) Sort()

Sort method sorts all key/value pairs contained in this object in place and returns undefined.

func (*URLSearchParams) ToString

func (u *URLSearchParams) ToString() string

ToString method of the URLSearchParams interface returns a query string suitable for use in a URL.

func (*URLSearchParams) Values

func (u *URLSearchParams) Values() [][]string

Values method of the URLSearchParams interface returns an iterator allowing iteration through all values contained in this object. The values are string objects.

type URLSearchParamsConstructor added in v0.4.0

type URLSearchParamsConstructor struct{}

URLSearchParamsConstructor Constructor

func (*URLSearchParamsConstructor) Exports added in v0.4.0

func (*URLSearchParamsConstructor) Exports() any

Exports instance URLSearchParams module

func (*URLSearchParamsConstructor) Global added in v0.4.0

func (*URLSearchParamsConstructor) Global()

Global it is a global module

Jump to

Keyboard shortcuts

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