Compare commits
No commits in common. "6a31c89f5393184dde5bb9e8db46f28d07723403" and "772bda8e934d094dfe0bd06c19ead65b4c41c9b4" have entirely different histories.
6a31c89f53
...
772bda8e93
|
@ -1,12 +0,0 @@
|
|||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
pub fn init_tracing() {
|
||||
// Set up logging
|
||||
tracing_subscriber::registry()
|
||||
.with(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| "nyazoom=debug,tower_http=debug".into()),
|
||||
)
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
.init();
|
||||
}
|
46
src/main.rs
46
src/main.rs
|
@ -26,8 +26,9 @@ use tokio_util::{
|
|||
|
||||
use tower_http::{limit::RequestBodyLimitLayer, services::ServeDir, trace::TraceLayer};
|
||||
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
mod cache;
|
||||
mod logging;
|
||||
mod nyazoom_headers;
|
||||
pub mod ssr;
|
||||
mod state;
|
||||
|
@ -40,9 +41,24 @@ use state::{AppState, UploadRecord};
|
|||
use crate::state::AsyncRemoveRecord;
|
||||
use crate::views::{DownloadLinkPage, HtmxPage, LinkView, Welcome};
|
||||
|
||||
pub mod error {
|
||||
use std::io::{Error, ErrorKind};
|
||||
|
||||
pub fn io_other(s: &str) -> Error {
|
||||
Error::new(ErrorKind::Other, s)
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
logging::init_tracing();
|
||||
// Set up logging
|
||||
tracing_subscriber::registry()
|
||||
.with(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| "nyazoom=debug,tower_http=debug".into()),
|
||||
)
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
.init();
|
||||
|
||||
// uses create_dir_all to create both .cache and serve inside it in one go
|
||||
util::make_dir(".cache/serve").await?;
|
||||
|
@ -69,7 +85,17 @@ async fn main() -> io::Result<()> {
|
|||
.layer(TraceLayer::new_for_http())
|
||||
.layer(middleware::from_fn(log_source));
|
||||
|
||||
serve(app).await;
|
||||
// Server creation
|
||||
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
|
||||
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
|
||||
axum::serve(
|
||||
listener,
|
||||
app.into_make_service_with_connect_info::<SocketAddr>(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
tracing::debug!("listening on http://{}/", addr);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -295,17 +321,3 @@ async fn download(
|
|||
|
||||
Ok(Redirect::to("/404.html").into_response())
|
||||
}
|
||||
|
||||
async fn serve(app: Router) {
|
||||
// // Server creation
|
||||
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
|
||||
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
|
||||
axum::serve(
|
||||
listener,
|
||||
app.into_make_service_with_connect_info::<SocketAddr>(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
tracing::debug!("listening on http://{}/", addr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue