Documentation
¶
Overview ¶
Package web provides Go struct definitions for Web API types used by transpiled TypeScript code. These types mirror the Web API spec (Request, Response, Headers, URL, etc.) with Go-idiomatic field access and methods.
Index ¶
- Variables
- func Atob(s string) string
- func Btoa(s string) string
- type CryptoKey
- type CryptoSubtle
- func (c *CryptoSubtle) Digest(algorithm any, data any) *promise.Promise[[]byte]
- func (c *CryptoSubtle) ImportKey(format string, keyData any, algorithm any, extractable bool, ...) *promise.Promise[any]
- func (c *CryptoSubtle) Sign(algorithm any, key any, data any) *promise.Promise[[]byte]
- func (c *CryptoSubtle) Verify(algorithm any, key any, signature any, data any) *promise.Promise[bool]
- type FormData
- func (f *FormData) Append(name, value string)
- func (f *FormData) Await() (*FormData, error)
- func (f *FormData) Delete(name string)
- func (f *FormData) ForEach(fn func(value any, key string))
- func (f *FormData) Get(name string) string
- func (f *FormData) Has(name string) bool
- func (f *FormData) Set(name, value string)
- type Headers
- func (h *Headers) Append(name, value string)
- func (h *Headers) Delete(name string)
- func (h *Headers) Entries() [][]any
- func (h *Headers) ForEach(fn func(value, key string))
- func (h *Headers) Get(name string) string
- func (h *Headers) GetSetCookie() []string
- func (h *Headers) Has(name string) bool
- func (h *Headers) Raw() http.Header
- func (h *Headers) Set(name, value string)
- type Request
- type Response
- type TextDecoder
- type TextEncoder
- type URL
Constants ¶
This section is empty.
Variables ¶
var Crypto = true
Crypto is a truthy sentinel indicating crypto is always available in Go.
var Subtle = &CryptoSubtle{}
Subtle is the package-level SubtleCrypto singleton.
Functions ¶
Types ¶
type CryptoSubtle ¶ added in v0.5.0
type CryptoSubtle struct{}
CryptoSubtle implements a subset of the Web Crypto API (SubtleCrypto).
type FormData ¶
type FormData struct {
// contains filtered or unexported fields
}
FormData is a simplified FormData representation.
func NewFormData ¶
func NewFormData() *FormData
type Headers ¶
type Headers struct {
// contains filtered or unexported fields
}
Headers wraps http.Header with Web API-compatible methods.
func NewHeaders ¶
func (*Headers) GetSetCookie ¶
type Request ¶
type Request struct {
Url string
Method string
Headers *Headers
Body io.Reader
BodyUsed bool
Cache string
Credentials string
Integrity string
Keepalive bool
Mode string
Redirect string
Referrer string
ReferrerPolicy string
Signal any
}
Request represents a Web API Request.
func (*Request) ArrayBuffer ¶
ArrayBuffer returns the request body as bytes.
type Response ¶
type Response struct {
Body io.Reader
Headers *Headers
Status int
StatusText string
Ok bool
// contains filtered or unexported fields
}
Response represents a Web API Response.
func NewResponse ¶
func ResponseJSON ¶
ResponseJSON creates a JSON response.
func ResponseRedirect ¶
ResponseRedirect creates a redirect response.
func (*Response) ArrayBuffer ¶ added in v0.5.0
ArrayBuffer returns the response body as a byte slice.
func (*Response) Blob ¶ added in v0.5.0
Blob returns the response body as a byte slice (simplified).
func (*Response) FormData ¶ added in v0.5.0
FormData parses the response body as multipart form data.
type TextDecoder ¶ added in v0.5.0
type TextDecoder struct {
// contains filtered or unexported fields
}
TextDecoder provides TextDecoder.decode().
func NewTextDecoder ¶ added in v0.5.0
func NewTextDecoder(args ...string) *TextDecoder
func (*TextDecoder) Decode ¶ added in v0.5.0
func (d *TextDecoder) Decode(buf any) string
type TextEncoder ¶
type TextEncoder struct{}
TextEncoder provides TextEncoder.encode().
func NewTextEncoder ¶
func NewTextEncoder() *TextEncoder
func (*TextEncoder) Encode ¶
func (e *TextEncoder) Encode(input any) []byte