Files
wren/test/web/response.wren
T
retoor 5a4054ec66 feat: add example scripts for argparse, bytes, dataset, html, markdown, uuid, wdantic, and web chat modules
Add comprehensive demo scripts showcasing the usage of multiple Wren modules including argument parsing, byte manipulation, in-memory dataset operations, HTML encoding/slugification, markdown-to-HTML conversion, UUID generation/validation, schema validation with wdantic, and a full web chat application with REST endpoints.
2026-01-24 22:40:22 +00:00

20 lines
688 B
JavaScript
Vendored

// retoor <retoor@molodetz.nl>
import "web" for Response
var r1 = Response.text("Hello")
System.print(r1.body) // expect: Hello
System.print(r1.headers["Content-Type"].contains("text/plain")) // expect: true
var r2 = Response.html("<h1>Hi</h1>")
System.print(r2.body) // expect: <h1>Hi</h1>
System.print(r2.headers["Content-Type"].contains("text/html")) // expect: true
var r3 = Response.json({"name": "test"})
System.print(r3.body.contains("name")) // expect: true
System.print(r3.headers["Content-Type"].contains("application/json")) // expect: true
var r4 = Response.redirect("/login")
System.print(r4.status) // expect: 302
System.print(r4.headers["Location"]) // expect: /login