did stuff?

This commit is contained in:
Rakarake 2026-03-28 20:47:31 +01:00
parent bac4e5d8c6
commit cb0447e53c
3 changed files with 29 additions and 4 deletions

View file

@ -8,3 +8,4 @@ axum = "*"
tokio = { version = "*", features = ["full"] }
log = "0.4"
pretty_env_logger = "0.4"
tower-http = { version = "*", features = ["auth"] }

View file

@ -5,8 +5,6 @@ use log::info;
use tokio::fs;
use std::path::PathBuf;
const MAXIMUM_PACKET_SIZE: usize = (2 << 20) * 10;
#[derive(Clone)]
struct AppState {
root: PathBuf,
@ -25,14 +23,17 @@ async fn main() -> io::Result<()> {
port_str.parse::<u16>().expect("PORT is malformed")
} else { 3236 };
let maximum_packet_size: usize = if let Ok(port_str) = var("MDFBOUNCER_MAXIMUM_PACKET_SIZE") {
port_str.parse::<usize>().expect("MDFBOUNCER_MAXIMUM_PACKET_SIZE is malformed")
} else { (2 << 20) * 10 };
let state = Arc::new(AppState { root: PathBuf::from(target_path) });
let app = Router::new()
.route("/{*key}", put(put_file))
.route("/{*key}", delete(delete_file))
.with_state(state)
.layer(DefaultBodyLimit::max(MAXIMUM_PACKET_SIZE));
.layer(DefaultBodyLimit::max(maximum_packet_size));
let listener = tokio::net::TcpListener::bind(("localhost", port))
.await