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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Minimal Server Example
//! =================
//!
//! Start the server:
//! ```
//! $ cargo run --package servlin --example minimal
//!     Finished dev [unoptimized + debuginfo] target(s) in 0.04s
//!      Running `target/debug/examples/minimal`
//! ^C
//! ```
//!
//! Make a request to it:
//! ```
//! $ curl -v http://127.0.0.1:8000/
//! *   Trying 127.0.0.1:8000...
//! * Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
//! > GET / HTTP/1.1
//! > Host: 127.0.0.1:8000
//! > User-Agent: curl/7.79.1
//! > Accept: */*
//! >
//! * Mark bundle as not supporting multiuse
//! < HTTP/1.1 404 Not Found
//! < content-type: text/plain; charset=UTF-8
//! < content-length: 9
//! <
//! * Connection #0 to host 127.0.0.1 left intact
//! not found
//! $
//! ```
#![forbid(unsafe_code)]
use servlin::reexport::{safina_executor, safina_timer};
use servlin::{socket_addr_127_0_0_1, HttpServerBuilder, Request, Response};

pub fn main() {
    safina_timer::start_timer_thread();
    let executor = safina_executor::Executor::default();
    executor
        .block_on(
            HttpServerBuilder::new()
                .listen_addr(socket_addr_127_0_0_1(8000))
                .spawn_and_join(|_req: Request| Response::not_found_404()),
        )
        .unwrap();
}