Builds a routed protocol switch. The callback runs on the connection fiber after the 101 head has been written.
Signature
upgrade_response :: (
protocol: string,
handler: Upgrade_Handler,
data: *void = null
) -> Response
Io :: #import "Extensions/Io";
serve_protocol :: (link: Link, pending: [] u8, data: *void) {
Io.write(link.writer, "hello");
}
main :: () {
response := upgrade_response("example", serve_protocol);
assert(response.status == 101);
assert(response.upgrade == serve_protocol);
protocol, _ := find_header(response.headers, "Upgrade");
assert(protocol == "example");
}