♻️ Use a prelude to clean up the unused imports for `tracing`

main
_ 2020-11-08 16:00:31 +00:00
parent c5691d9d05
commit 435232bf6c
7 changed files with 10 additions and 23 deletions

View File

@ -17,12 +17,10 @@ use hyper::{
StatusCode, StatusCode,
}; };
use serde::Deserialize; use serde::Deserialize;
use tracing::{
debug, error, info, trace, warn,
};
use ptth::{ use ptth::{
http_serde::RequestParts, http_serde::RequestParts,
prelude::*,
server::file_server, server::file_server,
}; };

View File

@ -8,7 +8,8 @@ use tokio::{
sync::oneshot, sync::oneshot,
time::delay_for, time::delay_for,
}; };
use tracing::{debug, error, info, trace, warn};
use crate::prelude::*;
pub fn init () -> oneshot::Receiver <()> { pub fn init () -> oneshot::Receiver <()> {
let (tx, rx) = oneshot::channel::<()> (); let (tx, rx) = oneshot::channel::<()> ();

View File

@ -1,5 +1,3 @@
pub mod http_serde;
// It's easier if the server can stream its response body // It's easier if the server can stream its response body
// back to the relay un-changed inside its request body // back to the relay un-changed inside its request body
// So we wrap the server's actual response head // So we wrap the server's actual response head
@ -7,12 +5,11 @@ pub mod http_serde;
pub const PTTH_MAGIC_HEADER: &str = "X-PTTH-2LJYXWC4"; pub const PTTH_MAGIC_HEADER: &str = "X-PTTH-2LJYXWC4";
// Basically binaries, but in the lib we can do experimental
// test stuff like spawn them both in the same process
pub mod git_version; pub mod git_version;
pub mod graceful_shutdown; pub mod graceful_shutdown;
pub mod http_serde;
pub mod load_toml; pub mod load_toml;
pub mod prelude;
pub mod relay; pub mod relay;
pub mod server; pub mod server;

1
src/prelude.rs Normal file
View File

@ -0,0 +1 @@
pub use tracing::{debug, error, info, trace, warn};

View File

@ -23,15 +23,13 @@ use tokio::{
channel, channel,
}, },
}; };
use tracing::{ use tracing::instrument;
debug, error, info, trace, warn,
instrument,
};
use regex::Regex; use regex::Regex;
use crate::{ use crate::{
http_serde, http_serde,
prelude::*,
prefix_match, prefix_match,
}; };

View File

@ -16,11 +16,10 @@ use tokio::{
sync::oneshot, sync::oneshot,
time::delay_for, time::delay_for,
}; };
use tracing::{debug, error, info, warn};
use crate::{ use crate::{
http_serde, http_serde,
prefix_match, prelude::*,
}; };
pub mod file_server; pub mod file_server;
@ -32,14 +31,6 @@ struct ServerState {
hidden_path: Option <PathBuf>, hidden_path: Option <PathBuf>,
} }
fn status_reply (c: http_serde::StatusCode, body: &str) -> http_serde::Response
{
let mut r = http_serde::Response::default ();
r.status_code (c)
.body_bytes (body.as_bytes ().to_vec ());
r
}
async fn handle_req_resp <'a> ( async fn handle_req_resp <'a> (
state: &Arc <ServerState>, state: &Arc <ServerState>,
req_resp: reqwest::Response req_resp: reqwest::Response

View File

@ -1,6 +1,7 @@
- Not working behind Nginx (Works okay behind Caddy) - Not working behind Nginx (Works okay behind Caddy)
- Reduce idle memory use? - Reduce idle memory use?
- Compress bad passwords file
- Package templates into exe for release - Package templates into exe for release
- Redirect to add trailing slashes - Redirect to add trailing slashes
- Add file size in directory listing - Add file size in directory listing