use warp::{Filter, body, get, path, post, serve};
mod config;
mod download;
mod form;
#[tokio::main]
async fn main() {
use config::{BIND_IP, BIND_PORT, DOMAIN, MAX_BODY_SIZE, SECRET};
let _ = *SECRET;
let _ = *DOMAIN;
let routes = get().map(form::render_form).or(post()
.and(body::content_length_limit(MAX_BODY_SIZE))
.and(body::form())
.and(path("dl"))
.and_then(download::handle_download));
println!("Running aa-fastlink {}", env!("CARGO_PKG_RUST_VERSION"));
println!("Binding to http://{}:{}", *BIND_IP, *BIND_PORT);
serve(routes).run((*BIND_IP, *BIND_PORT)).await;
}