using Astralis; using Invercargill; using Invercargill.DataStructures; // Simple handler for /hello endpoint class HelloEndpoint : Object, Endpoint { public async HttpResult handle_request(HttpContext http_context, RouteContext route) throws Error { print("Handling /hello\n"); return new HttpStringResult("Hello from Astralis!"); } } // Simple handler for /json endpoint class JsonEndpoint : Object, Endpoint { public async HttpResult handle_request(HttpContext http_context, RouteContext route) throws Error { print("Handling /json\n"); return new HttpStringResult("{ \"message\": \"Hello JSON\" }") .set_header("Content-Type", "application/json"); } } void main() { var application = new WebApplication(8080); application.add_endpoint(new EndpointRoute("/hello")); application.add_endpoint(new EndpointRoute("/json")); application.run(); }