Documentation
¶
Overview ¶
Package fetch provides the HTTP API exposed to WebGo programs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBodyConsumed = errors.New("response body has already been consumed")
ErrBodyConsumed reports a second attempt to consume one response body.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API binds WebGo Fetch calls to one page URL and network executor.
func New ¶
func New(baseURL *url.URL, do func(context.Context, *network.Request) (*network.Response, error)) *API
New creates a page-scoped Fetch API.
func NewPage ¶
func NewPage(ctx context.Context, baseURL *url.URL, do func(context.Context, *network.Request) (*network.Response, error), enqueue func(func()) bool) *API
NewPage creates an asynchronous Fetch API bound to a page callback queue.
type CredentialsMode ¶
type CredentialsMode string
CredentialsMode controls Cookie and HTTP authentication handling.
const ( CredentialsOmit CredentialsMode = "omit" CredentialsSameOrigin CredentialsMode = "same-origin" CredentialsInclude CredentialsMode = "include" )
type Request ¶
type Request struct {
Method string
URL string
Header Header
Body []byte
Text string
Credentials CredentialsMode
}
Request describes an HTTP request issued by a WebGo program. Body takes precedence over Text when both are set.
type Response ¶
type Response struct {
Status int
StatusText string
URL string
Redirected bool
Header Header
// contains filtered or unexported fields
}
Response is delivered to a successful Fetch callback. Additional response metadata and body helpers are added by the HTTP lifecycle implementation.
Click to show internal directories.
Click to hide internal directories.