use std::sync::Arc;
use axum::routing::{delete, get, post, put};
use axum::Router;
use super::handlers::{
delete_torrent_handler, download_torrent_handler, get_torrent_info_handler, get_torrents_handler,
update_torrent_info_handler, upload_torrent_handler,
};
use crate::common::AppData;
pub fn router_for_single_resources(app_data: Arc<AppData>) -> Router {
let torrent_info_routes = Router::new()
.route("/", get(get_torrent_info_handler).with_state(app_data.clone()))
.route("/", put(update_torrent_info_handler).with_state(app_data.clone()))
.route("/", delete(delete_torrent_handler).with_state(app_data.clone()));
Router::new()
.route("/upload", post(upload_torrent_handler).with_state(app_data.clone()))
.route("/download/:info_hash", get(download_torrent_handler).with_state(app_data))
.nest("/:info_hash", torrent_info_routes)
}
pub fn router_for_multiple_resources(app_data: Arc<AppData>) -> Router {
Router::new().route("/", get(get_torrents_handler).with_state(app_data))
}