# A stand-in API on a loopback port for message.j and rest404.j: every# GET /users/:id answers 404 with the body "no such user".use httpd;
usetask;
import"web.j"as web;
defconstADDRasstringinit"127.0.0.1:18404";
exportdefconstURLasstringinit"http://" + ADDR;
funcnoUser(ctx asweb.Context) {
web.text($ctx, 404, "no such user");
}
# start listens, serves from a task and returns the server handle; stop it# with httpd.shutdown when done.exportfuncstart() {
def app asweb.App initweb.new();
$app = web.get($app, "/users/:id", noUser);
def srv ashttpd.Server inithttpd.listen(ADDR);
def t astaskofnullinitspawn {
web.serveOn($app, $srv);
returnnull;
};
task.discard($t);
return$srv;
}