commit - cf461aa4ea60df92c2a02511c9b27e6b1b89843b
commit + 1106be5093dfa29041632c36c853c52a0bce1ce7
blob - /dev/null
blob + 1a93151e095fc4fbd0de9c27f22775fd3d8fc6ab (mode 644)
--- /dev/null
+++ http/README
+The http module implements a http server. Functions (handlers) can be
+associated to a specific route using [[handle]]. Routes are matched
+per [[fnmatch::fnmatch]].
+
+The http module relies on the event loop [[ev]].
+
+Sample code:
+
+ use ev;
+ use fmt;
+ use http;
+
+ fn homepage(
+ req: *http::request,
+ res: *http::reswriter
+ ) (void | io::error) = {
+ http::reply(req, res, 200, "OK")?;
+ http::header(res, "Content-Type", "text/plain")?;
+ fmt::fprintln(res, "Hello, world!")?;
+ };
+
+ fn page2(...) // ...
+
+ export fn main() void = {
+ let sock = // ...
+
+ http::listen_sock(sock);
+
+ http::handle("/", &homepage);
+ http::handle("/2", &page2);
+
+ ev::mainloop()!;
+ };