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:
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user