share/src/main.rs

33 lines
799 B
Rust
Raw Normal View History

2022-10-21 12:12:53 +02:00
pub mod lib;
2022-10-21 11:07:34 +02:00
pub mod vistas;
2022-10-20 23:20:04 +02:00
use axum::{
routing::{get, post},
Router,
};
use std::net::SocketAddr;
2022-10-24 10:23:47 +02:00
use crate::lib::env_listen_port;
2022-10-21 11:07:34 +02:00
2022-10-21 15:17:31 +02:00
use crate::vistas::{download::get_file, root::basic, upload::upload};
2022-10-20 23:20:04 +02:00
#[tokio::main]
async fn main() {
// initialize tracing
tracing_subscriber::fmt::init();
// build our application with a route
let app = Router::new()
2022-10-21 11:07:34 +02:00
.route("/", get(basic))
2022-10-21 18:11:41 +02:00
.route("/", post(upload))
2022-10-21 13:36:53 +02:00
.route("/f/:hash", get(get_file));
2022-10-20 23:20:04 +02:00
// run our app with hyper
// `axum::Server` is a re-export of `hyper::Server`
2022-10-24 10:23:47 +02:00
let addr = SocketAddr::from(([127, 0, 0, 1], env_listen_port()));
2022-10-20 23:20:04 +02:00
tracing::debug!("listening on {}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
}