deno-http-worker

Similarly to deno-vm, deno-http-worker lets you securely spawn Deno http servers.
Usage
import { newDenoHTTPWorker } from 'deno-http-worker';
let worker = await newDenoHTTPWorker(
`export default async function (req: Request): Promise<Response> {
return Response.json({ ok: req.url })
}`,
{ printOutput: true, runFlags: ["--alow-net"] }
);
let json = await worker.client
.get("https://hello/world?query=param")
.json();
console.log(json)
worker.terminate();
Internals
Deno-http-worker connects to the Deno process over a single Unix socket http2 connection to make requests. This is for performance and efficiency. As a result, the worker does not provide an address or url, but instead returns an instance of a got client that you can make requests with. This ensures that only the underlying http2.ClientHttp2Session
is used to make requests.
If you need more advanced usage that cannot be covered by got
, please open a ticket.