From cb2517bee240c592c07e77c1507877cf47ace553 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 15 Mar 2025 01:16:39 +0800 Subject: Separate paths into segments --- main.ha | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'main.ha') 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)?; }; -- cgit v1.2.3