vweb: support `-d trace_request` and `-d trace_response`

pull/13800/head
Delyan Angelov 2022-03-21 19:48:47 +02:00
parent 178afd006b
commit 9ad64b0bd8
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 9 additions and 1 deletions

View File

@ -459,7 +459,12 @@ fn handle_conn<T>(mut conn net.TcpConn, mut app T, routes map[string]Route) {
}
return
}
$if trace_request ? {
dump(req)
}
$if trace_request_url ? {
dump(req.url)
}
// URL Parse
url := urllib.parse(req.url) or {
eprintln('error parsing path: $err')
@ -702,6 +707,9 @@ pub fn not_found() Result {
}
fn send_string(mut conn net.TcpConn, s string) ? {
$if trace_response ? {
eprintln('> send_string:\n$s\n')
}
conn.write(s.bytes()) ?
}