diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-15 01:16:39 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-15 01:16:39 +0800 |
commit | cb2517bee240c592c07e77c1507877cf47ace553 (patch) | |
tree | ea316415dfb1f29684c80e108762e4a66c937fb4 /main.ha | |
parent | Add horrible patch needed to make net::uri work (diff) | |
download | forge-cb2517bee240c592c07e77c1507877cf47ace553.tar.gz forge-cb2517bee240c592c07e77c1507877cf47ace553.tar.zst forge-cb2517bee240c592c07e77c1507877cf47ace553.zip |
Separate paths into segments
Diffstat (limited to '')
-rw-r--r-- | main.ha | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -10,6 +10,7 @@ use net::dial; use net::http; use net::ip; use net::tcp; +use net::uri; use os; use memio; use io; @@ -58,8 +59,10 @@ export fn main() void = { }; }; -export fn handlereq(conn: io::handle, request: *http::request) (void | io::error | nomem) = { +export fn handlereq(conn: io::handle, request: *http::request) (void | io::error | nomem | net::uri::invalid) = { htmpl::write(conn, "HTTP/1.1 200 OK\r\n")?; htmpl::write(conn, "Content-Type: text/html\r\n\r\n")?; - tp_index(conn)?; + let segments = segments_from_path(request.target.raw_path)?; + defer free_segments(segments); + tp_index(conn, segments)?; }; |