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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#![doc(html_root_url = "https://docs.rs/gotham/0.3.0")]
#![warn(missing_docs, deprecated)]
#![cfg_attr(feature = "ci", deny(warnings))]
#![cfg_attr(
feature = "cargo-clippy",
allow(
clippy::needless_lifetimes,
clippy::should_implement_trait,
clippy::unit_arg,
clippy::match_wild_err_arm,
clippy::new_without_default,
clippy::wrong_self_convention,
clippy::mutex_atomic,
clippy::borrowed_box,
clippy::get_unwrap,
)
)]
#![doc(test(no_crate_inject, attr(deny(warnings))))]
#![deny(private_in_public)]
pub mod error;
pub mod extractor;
pub mod handler;
pub mod helpers;
pub mod middleware;
pub mod pipeline;
pub mod router;
mod service;
pub mod state;
pub mod test;
pub mod plain;
pub mod tls;
use std::net::ToSocketAddrs;
use tokio::net::TcpListener;
use tokio::runtime::{self, Runtime};
pub use plain::*;
pub use tls::start as start_with_tls;
fn new_runtime(threads: usize) -> Runtime {
runtime::Builder::new()
.core_threads(threads)
.name_prefix("gotham-worker-")
.build()
.unwrap()
}
fn tcp_listener<A>(addr: A) -> TcpListener
where
A: ToSocketAddrs + 'static,
{
let addr = addr
.to_socket_addrs()
.expect("unable to parse listener address")
.next()
.expect("unable to resolve listener address");
TcpListener::bind(&addr).expect("unable to open TCP listener")
}