Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › compiler/ › Maker/ › WebServer.zig › start
start
WebServer.start
pub fn start (ws : *WebServer ) error
File
Code
pub fn start (ws : *WebServer ) error {AlreadyReported }!void {
assert (ws .tcp_server == null );
assert (ws .serve_task == null );
const graph = ws .graph ;
const io = graph .io ;
ws .tcp_server = ws .listen_address .listen (io , .{ .reuse_address = true }) catch |err | {
log .err ("failed to listen to port {d}: {t}" , .{ ws .listen_address .getPort (), err });
return error .AlreadyReported ;
};
ws .serve_task = io .concurrent (serve , .{ws }) catch |err | {
log .err ("unable to spawn web server thread: {t}" , .{err });
ws .tcp_server .?.deinit (io );
ws .tcp_server = null ;
return error .AlreadyReported ;
};
log .info ("web interface listening at http://{f}/" , .{ws .tcp_server .?.socket .address });
if (ws .listen_address .getPort () == 0 ) {
log .info ("hint: pass '--webui={f}' to use the same port next time" , .{ws .tcp_server .?.socket .address });
}
}