diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-15 11:38:23 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-15 11:38:23 +0800 |
commit | 96f9c66a1ac41f36f9fb232ebeb53063368775ab (patch) | |
tree | 9ccbd97bd7f2d5cd82a4f33d31eb2da4594e03ad /req.ha | |
parent | Use strings::freeall directly instead of wrapping it (diff) | |
download | forge-96f9c66a1ac41f36f9fb232ebeb53063368775ab.tar.gz forge-96f9c66a1ac41f36f9fb232ebeb53063368775ab.tar.zst forge-96f9c66a1ac41f36f9fb232ebeb53063368775ab.zip |
Split the request handler to req.ha
Diffstat (limited to 'req.ha')
-rw-r--r-- | req.ha | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -0,0 +1,13 @@ +use htmpl; +use io; +use net::http; +use net::uri; +use strings; + +export fn handlereq(conn: io::handle, request: *http::request) (void | io::error | nomem | uri::invalid) = { + htmpl::write(conn, "HTTP/1.1 200 OK\r\n")?; + htmpl::write(conn, "Content-Type: text/html\r\n\r\n")?; + let segments = segments_from_path(request.target.raw_path)?; + defer strings::freeall(segments); + tp_index(conn, segments)?; +}; |