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
#![forbid(missing_docs)]
#![forbid(unsafe_code)]
#![doc = include_str!("../README.md")]

mod macros;
mod request;
mod response;
mod server;
mod url;
mod util;

#[cfg(feature = "websocket")]
mod ws;

pub use request::Request;
pub use response::{Headers, Response, ResponseLike, DEFAULT_HTTP_VERSION};
pub use server::{Server, Stream, DEFAULT_BUFFER_SIZE};
pub use url::Url;
pub use util::{HttpVersion, Method};

#[cfg(feature = "websocket")]
/// A WebSocket connection.
pub type WebSocket<'a> = tungstenite::WebSocket<&'a mut Stream>;

#[cfg(feature = "tls")]
// Re-export needed structs for `Server::new(...)` with TLS.
// TlsStream might also be needed for websockets.
pub use native_tls::{Identity, TlsAcceptor, TlsStream};

/// A type alias for `std::io::Result<()>`
/// used in `Server::new()?.run(...)`.
///
/// `Server::run` returns type `!` (never) so using `Ok(())` is not needed.
pub type Result = std::io::Result<()>;