Documentation
¶
Overview ¶
Package http the http JS implementation
Index ¶
- func NewResponse(vm *goja.Runtime, res *http.Response) goja.Value
- type FileData
- type FormData
- func (f *FormData) Append(name string, value any, filename string) (ret goja.Value)
- func (f *FormData) Delete(name string)
- func (f *FormData) Entries() any
- func (f *FormData) Get(name string) any
- func (f *FormData) GetAll(name string) any
- func (f *FormData) Has(name string) bool
- func (f *FormData) Keys() any
- func (f *FormData) Set(name string, value any, filename string)
- func (f *FormData) Values() any
- type Http
- func (h *Http) Get(call goja.FunctionCall, vm *goja.Runtime) (ret goja.Value)
- func (h *Http) Head(call goja.FunctionCall, vm *goja.Runtime) (ret goja.Value)
- func (h *Http) Post(call goja.FunctionCall, vm *goja.Runtime) (ret goja.Value)
- func (h *Http) Request(call goja.FunctionCall, vm *goja.Runtime) (ret goja.Value)
- func (h *Http) Template(call goja.FunctionCall, vm *goja.Runtime) (ret goja.Value)
- type Module
- type NativeFormData
- type NativeURLSearchParams
- type Response
- type URLSearchParams
- func (u *URLSearchParams) Append(name, value string)
- func (u *URLSearchParams) Delete(name string)
- func (u *URLSearchParams) Entries() any
- func (u *URLSearchParams) ForEach(call goja.FunctionCall, vm *goja.Runtime) (ret goja.Value)
- func (u *URLSearchParams) Get(name string) any
- func (u *URLSearchParams) GetAll(name string) []string
- func (u *URLSearchParams) Has(name string) bool
- func (u *URLSearchParams) Keys() []string
- func (u *URLSearchParams) Set(name, value string)
- func (u *URLSearchParams) Sort()
- func (u *URLSearchParams) ToString() string
- func (u *URLSearchParams) Values() [][]string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
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 ¶
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 ¶
Delete method of the FormData interface deletes a key and its value(s) from a FormData object.
func (*FormData) Entries ¶
Entries method returns an iterator which iterates through all key/value pairs contained in the FormData.
func (*FormData) Get ¶
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 ¶
GetAll method of the FormData interface returns all the values associated with a given key from within a FormData object.
func (*FormData) Has ¶
Has method of the FormData interface returns whether a FormData object contains a certain key.
func (*FormData) Keys ¶
Keys method returns an iterator which iterates through all keys contained in the FormData. The keys are strings.
type Http ¶
type Http struct {
// contains filtered or unexported fields
}
Http module for fetching resources (including across the network).
func (*Http) Post ¶
Post Make a POST request with URL, optional body, optional headers. Send POST with multipart: http.post(url, new FormData({'bytes': new Uint8Array([0]).buffer})) Send POST with x-www-form-urlencoded: http.post(url, new URLSearchParams({'key': 'foo', 'value': 'bar'})) Send POST with json: http.post(url, {'key': 'foo'})
type NativeFormData ¶
type NativeFormData struct{}
NativeFormData js global module
func (*NativeFormData) Exports ¶
func (*NativeFormData) Exports() any
Exports returns module instance
type NativeURLSearchParams ¶
type NativeURLSearchParams struct{}
NativeURLSearchParams Native module
func (*NativeURLSearchParams) Exports ¶
func (*NativeURLSearchParams) Exports() any
Exports instance URLSearchParams module
func (*NativeURLSearchParams) Global ¶
func (*NativeURLSearchParams) Global()
Global it is a global module
type Response ¶
type Response struct {
Headers http.Header // response headers.
Status int // HTTP status code.
StatusText string // HTTP status message corresponding to the HTTP status code.
Ok bool // true if response Status in the range 200-299.
// contains filtered or unexported fields
}
Response wraps the given response
func (*Response) JsonEncodable ¶
JsonEncodable allows custom JSON encoding by JSON.stringify()
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.