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.
22 lines
596 B
JavaScript
Vendored
22 lines
596 B
JavaScript
Vendored
// retoor <retoor@molodetz.nl>
|
|
|
|
import "web" for Router
|
|
|
|
var router = Router.new()
|
|
router.get("/", Fn.new { |r| "home" })
|
|
router.get("/users/:id", Fn.new { |r| "user" })
|
|
router.post("/api/data", Fn.new { |r| "data" })
|
|
|
|
var m1 = router.match("GET", "/")
|
|
System.print(m1 != null) // expect: true
|
|
|
|
var m2 = router.match("GET", "/users/123")
|
|
System.print(m2 != null) // expect: true
|
|
System.print(m2["params"]["id"]) // expect: 123
|
|
|
|
var m3 = router.match("POST", "/api/data")
|
|
System.print(m3 != null) // expect: true
|
|
|
|
var m4 = router.match("GET", "/notfound")
|
|
System.print(m4 == null) // expect: true
|