// Server-Sent Events: hijack the response, write the stream directly, return
// {responseHandled: true} so rest-vir leaves it alone.
[HttpMethod.Get]({response}) {
response.hijack();
response.raw.writeHead(HttpStatus.Ok, {
'content-type': 'text/event-stream',
'cache-control': 'no-cache',
'x-no-compression': 'true',
});
response.raw.write(`data: hello\n\n`);
response.raw.end();
return {responseHandled: true};
}
The output an endpoint method implementation must return. Either:
{responseHandled: true}to indicate the implementation already wrote the response (e.g. SSE streaming or a hijacked raw response).