1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use ehttpd::{
http::{
request::Request,
response::Response,
responseext::{ResponseBodyExt, ResponseExt},
},
log::{self, WARN},
Server,
};
fn main() {
log::set_level(WARN);
let request_handler = |_: &mut Request| {
let mut response = Response::new_200_ok();
response.set_body_static(b"Hello world\r\n");
response
};
let server: Server = Server::new("[::]:9999", 64, 4096).expect("failed to start server");
server.exec(request_handler).expect("server failed");
}