aboutsummaryrefslogtreecommitdiff
path: root/main.ha
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-15 01:16:39 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-15 01:16:39 +0800
commitcb2517bee240c592c07e77c1507877cf47ace553 (patch)
treeea316415dfb1f29684c80e108762e4a66c937fb4 /main.ha
parentAdd horrible patch needed to make net::uri work (diff)
downloadforge-cb2517bee240c592c07e77c1507877cf47ace553.tar.gz
forge-cb2517bee240c592c07e77c1507877cf47ace553.tar.zst
forge-cb2517bee240c592c07e77c1507877cf47ace553.zip
Separate paths into segments
Diffstat (limited to '')
-rw-r--r--main.ha7
1 files changed, 5 insertions, 2 deletions
diff --git a/main.ha b/main.ha
index 39616b5..2c59c3d 100644
--- a/main.ha
+++ b/main.ha
@@ -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)?;
};