feat: add merge_all_wren utility, strutil demo, and 7 new API manual pages
Add WrenFileReader class in apps/merge_all_wren.wren for recursive .wren file discovery and content printing. Introduce example/strutil_demo.wren demonstrating case conversion, hex encoding, SHA256 hashing, string repetition, padding, HTML/JSON escaping, and URL encoding/decoding. Create manual/api pages for argparse, dataset, html, markdown, uuid, wdantic, and web modules. Update manual/api/index.html sidebar and module count from 21 to 28, adding links and cards for the new modules.
This commit is contained in:
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "web" for Request
|
||||
|
||||
var headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "text/html",
|
||||
"Cookie": "session=abc123; user=alice"
|
||||
}
|
||||
|
||||
var req = Request.new_("POST", "/api/users", {"page": "1", "limit": "10"}, headers, "{\"name\":\"Alice\"}", {"id": "42"}, null)
|
||||
|
||||
System.print(req.method) // expect: POST
|
||||
System.print(req.path) // expect: /api/users
|
||||
System.print(req.query["page"]) // expect: 1
|
||||
System.print(req.query["limit"]) // expect: 10
|
||||
System.print(req.params["id"]) // expect: 42
|
||||
System.print(req.body) // expect: {"name":"Alice"}
|
||||
|
||||
System.print(req.header("Content-Type")) // expect: application/json
|
||||
System.print(req.header("content-type")) // expect: application/json
|
||||
System.print(req.header("ACCEPT")) // expect: text/html
|
||||
System.print(req.header("X-Missing") == null) // expect: true
|
||||
|
||||
var json = req.json
|
||||
System.print(json["name"]) // expect: Alice
|
||||
|
||||
var cookies = req.cookies
|
||||
System.print(cookies["session"]) // expect: abc123
|
||||
System.print(cookies["user"]) // expect: alice
|
||||
|
||||
var formBody = "username=bob&password=secret"
|
||||
var formReq = Request.new_("POST", "/login", {}, {"Content-Type": "application/x-www-form-urlencoded"}, formBody, {}, null)
|
||||
var form = formReq.form
|
||||
System.print(form["username"]) // expect: bob
|
||||
System.print(form["password"]) // expect: secret
|
||||
Reference in New Issue
Block a user