Runs the app until it is stopped: SIGINT or SIGTERM (when config.handle_signals), or
shutdown(*app) from another thread. One scheduler per config.threads (default: the
processor count), each with its own listener on the same port. Returns once the servers have
stopped; the error says why it could not start (the port is taken, two routes conflict, the TLS
configuration is unusable) and is .NONE for a clean stop.
hello :: () -> string {
return "hello";
}
main :: () {
app: App;
defer free_app(*app);
get(*app, "/hello", hello);
error := serve(*app); // returns after Ctrl-C
if error.kind != .NONE print("%\n", error_text(error));
}This one is only checked to compile, not run.
serve :: (app: *App) -> Serve_Error
Parameters
- app: *App