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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#![allow(unused_imports)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![doc(html_logo_url = "https://lambdastackio.github.io/static/images/lambdastack-200x200.png",
html_favicon_url = "https://lambdastackio.github.io/static/images/favicon.ico",
html_root_url = "https://lambdastackio.github.io/tokio-http2/tokio_http2/index.html")]
#[macro_use] extern crate log;
#[macro_use] extern crate bitflags;
#[macro_use] extern crate url;
#[macro_use] extern crate slog;
extern crate pretty_env_logger;
extern crate slog_term;
extern crate slog_json;
extern crate slog_stream;
extern crate slog_syslog;
extern crate unicase;
extern crate rustc_serialize;
extern crate byteorder;
extern crate mime;
extern crate mime_guess;
extern crate rand;
extern crate tempdir;
extern crate futures;
extern crate futures_cpupool;
extern crate httparse;
extern crate net2;
extern crate time;
extern crate chrono;
extern crate libc;
extern crate native_tls;
extern crate tokio_core;
extern crate tokio_proto;
extern crate tokio_service;
extern crate tokio_tls;
pub mod http;
pub mod version;
pub mod error;
pub mod status;
pub mod method;
pub mod router;
pub mod logger;
pub use status::StatusCode::{self, Ok, BadRequest, NotFound};
pub use version::HttpVersion;
pub use error::{Result, Error};
pub use url::Url;
pub use method::Method;
pub use http::{Request, Response};
pub use router::route::route::Route;
pub use router::Router;
pub use router::builder::RouterBuilder;
pub use logger::{Logger, LoggerLevel};
pub type Body = Vec<u8>;
pub type ContentType = String;
pub type ContentLength = u64;
pub type Headers = Vec<(String, String)>;
pub type Handler = fn(Request, String) -> Response;
use rand::Rng;
#[macro_export]
macro_rules! chain_result {
($first_expr:expr, $($try_expr:expr),*) => (
$first_expr $(.and_then(|_| $try_expr))*
);
($first_expr:expr, $($($arg:ident),+ -> $try_expr:expr),*) => (
$first_expr $(.and_then(|$($arg),+| $try_expr))*
);
}
pub mod server;
fn random_alphanumeric(len: usize) -> String {
rand::thread_rng().gen_ascii_chars().take(len).collect()
}