Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handle ¶
Handle registers fn as the single request handler and blocks forever. fn is called for every incoming HTTP request to the Worker. This must be called from main(); it never returns.
Uses the binding pattern from goflare/assets/worker.mjs:
binding.handleRequest is called per request with the JS Request object.
binding is accessed via js.Global().Get("context") — injected by wasm_exec.js Proxy.
func Ready ¶
func Ready()
Ready signals the Workers runtime that Go initialization is complete. Called automatically by Handle(). Call manually only if not using Handle().
It reads the callback from context.binding — the same instance-scoped door Handle() uses — never from a bare global. js.Global() is a Proxy (assets/wasm_exec_worker.js) that resolves ONLY the "context" property per wasm instance; every other name resolves to the single object shared by the whole isolate, where a second request would silently clobber the signal. See assets/worker.mjs's start() for the JS side of this contract.
Types ¶
type Request ¶
Request represents an incoming HTTP request to the Worker.
func (*Request) Body ¶
Body returns the raw request body bytes. It reads the body lazily on the first call.
func (*Request) Header ¶
Header returns the value of the named header, or "" if absent. Lookup is case-insensitive, per the Fetch Headers.get() contract — do not "fix" this by lowercasing key yourself; Headers.get() already does the right thing, and double-normalizing invites the exact bug this method replaces (see docs/PLAN.md at the time of this change: Headers.entries() lowercases names for iteration, but .get() matches case-insensitively — reading one as if it behaved like the other silently returned "" for every request).
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response is written by the handler and converted to a JS Response.
func (*Response) GetHeader ¶ added in v0.0.6
GetHeader returns a previously-set response header, or "" if absent.
func (*Response) SetHeader ¶ added in v0.0.6
SetHeader sets a response header. Usage: w.SetHeader("Content-Type", "application/json")
func (*Response) WriteHeader ¶
WriteHeader sets the HTTP status code.