27 lines
761 B
Rust
27 lines
761 B
Rust
pub mod announce;
|
|
pub mod files;
|
|
pub mod health;
|
|
pub mod peers;
|
|
pub mod search;
|
|
pub mod stats;
|
|
pub mod ws;
|
|
|
|
use axum::{routing::{get, post}, Router};
|
|
use tower_http::cors::CorsLayer;
|
|
use crate::state::SharedState;
|
|
|
|
pub fn router(state: SharedState) -> Router {
|
|
let api = Router::new()
|
|
.route("/health", get(health::health))
|
|
.route("/search", get(search::search))
|
|
.route("/files/{file_id}", get(files::get_file))
|
|
.route("/announce", post(announce::announce))
|
|
.route("/peers/{file_id}", get(peers::peers))
|
|
.route("/stats", get(stats::stats))
|
|
.route("/tracker/ws", get(ws::ws_handler))
|
|
.with_state(state);
|
|
|
|
Router::new()
|
|
.nest("/api/v1", api)
|
|
.layer(CorsLayer::permissive())
|
|
} |