fix: fix REST API and HTTP server examples

- Fix string interpolation issues: escape curly braces with \{ and \}
  since unescaped { triggers string interpolation
- Fix effectful function invocation: use "let _ = run main() with {}"
  instead of bare "main()" calls
- Use inline record types instead of type aliases (structural typing)
- Fix flake.nix to show build progress instead of suppressing output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 23:11:51 -05:00
parent 5edd8aea77
commit cdc4f47272
3 changed files with 64 additions and 82 deletions

View File

@@ -10,11 +10,7 @@ fn handleRequest(req: { method: String, path: String, body: String, headers: Lis
match req.path {
"/" => HttpServer.respond(200, "Welcome to Lux HTTP Server!"),
"/hello" => HttpServer.respond(200, "Hello, World!"),
"/json" => HttpServer.respondWithHeaders(
200,
"{\"message\": \"Hello from Lux!\"}",
[("Content-Type", "application/json")]
),
"/json" => HttpServer.respondWithHeaders(200, "\{\"message\": \"Hello from Lux!\"\}", [("Content-Type", "application/json")]),
"/echo" => HttpServer.respond(200, "You sent: " + req.body),
_ => HttpServer.respond(404, "Not Found: " + req.path)
}
@@ -45,4 +41,4 @@ fn main(): Unit with {Console, HttpServer} = {
}
// Run main
main()
let output = run main() with {}