I want to send some location info from the CF Object back to the browser in the HTML. The CF Object is available from the request.
async function handleRequest(request) {
response = await fetch(request);
return rewriter.transform(response);
}
const rewriter = new HTMLRewriter()
.on('body', new AttributeWriter())
class AttributeWriter {
async element(element) {
// ...
}
}
It looks like I’ll need to instantiate a new HtmlRewriter on every request and pass in the CF Object via the constructor.
Has anyone seen an actual API for HtmlRewriter? I.e., maybe there’s a way to pass more info via .transform()
. I’d like to know the function’s signature. But I’ve only found the manually-written doc page.