Skip to content

Commit 8c9810f

Browse files
committed
Only debug in development
1 parent cad7314 commit 8c9810f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/lib.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ pub fn middleware(app: Arc<App>) -> MiddlewareBuilder {
120120
}
121121

122122
let mut m = MiddlewareBuilder::new(R404(router));
123-
m.add(DebugMiddleware);
123+
if env == Env::Development {
124+
m.add(DebugMiddleware);
125+
}
124126
if env != Env::Test {
125127
m.add(conduit_log_requests::LogRequests(0));
126128
}
@@ -143,24 +145,24 @@ pub fn middleware(app: Arc<App>) -> MiddlewareBuilder {
143145
impl conduit_middleware::Middleware for DebugMiddleware {
144146
fn before(&self, req: &mut conduit::Request)
145147
-> Result<(), Box<std::fmt::Show + 'static>> {
146-
println!("version: {}", req.http_version());
147-
println!("method: {}", req.method());
148-
println!("scheme: {}", req.scheme());
149-
println!("host: {}", req.host());
150-
println!("path: {}", req.path());
151-
println!("query_string: {}", req.query_string());
148+
println!(" version: {}", req.http_version());
149+
println!(" method: {}", req.method());
150+
println!(" scheme: {}", req.scheme());
151+
println!(" host: {}", req.host());
152+
println!(" path: {}", req.path());
153+
println!(" query_string: {}", req.query_string());
152154
for &(k, ref v) in req.headers().all().iter() {
153-
println!("hdr: {}={}", k, v);
155+
println!(" hdr: {}={}", k, v);
154156
}
155157
Ok(())
156158
}
157159
fn after(&self, req: &mut conduit::Request,
158160
res: Result<conduit::Response, Box<std::fmt::Show + 'static>>)
159161
-> Result<conduit::Response, Box<std::fmt::Show + 'static>> {
160162
res.map(|res| {
161-
println!("<- {}", res.status);
163+
println!(" <- {}", res.status);
162164
for (k, v) in res.headers.iter() {
163-
println!("<- {} {}", k, v);
165+
println!(" <- {} {}", k, v);
164166
}
165167
res
166168
})

0 commit comments

Comments
 (0)