using Astralis; using Invercargill; using Invercargill.DataStructures; // Simple handler for /hello endpoint class HelloHandler : Object, RouteHandler { public async HttpResult handle_route(HttpContext http_context, RouteContext route_context) throws Error { print("Handling /hello\n"); return new HttpStringResult("Hello from Astralis!"); } } // Simple handler for /json endpoint class JsonHandler : Object, RouteHandler { public async HttpResult handle_route(HttpContext http_context, RouteContext route_context) throws Error { print("Handling /json\n"); return new HttpStringResult("{ \"message\": \"Hello JSON\" }") .set_header("Content-Type", "application/json"); } } void main() { var router = new Router(); var server = new Server(8080, router); router.map("/hello", new HelloHandler()); router.map("/json", new JsonHandler()); server.run(); }