| 12345678910111213141516171819202122 |
- using Astralis;
- using Invercargill;
- using Invercargill.DataStructures;
- void main() {
- var router = new Router();
- var server = new Server(8080, router);
-
- router.map_func("/hello", (context) => {
- print("Handling /hello\n");
- return new BufferedHttpResult.from_string("Hello from Astralis!");
- });
- router.map_func("/json", (context) => {
- print("Handling /json\n");
- var headers = new Catalogue<string, string>();
- headers.add("Content-Type", "application/json");
- return new BufferedHttpResult.from_string("{ \"message\": \"Hello JSON\" }", StatusCode.OK, headers);
- });
- server.run();
- }
|