pub mod autocomplete; pub mod opensearch; pub mod search; use std::net::SocketAddr; use axum::{http::header, routing::get, Router}; pub const BIND_ADDRESS: &str = "0.0.0.0:28019"; pub async fn run() { let app = Router::new() .route( "/", get(|| async { ( [(header::CONTENT_TYPE, "text/html; charset=utf-8")], include_str!("assets/index.html"), ) }), ) .route( "/style.css", get(|| async { ( [(header::CONTENT_TYPE, "text/css; charset=utf-8")], include_str!("assets/style.css"), ) }), ) .route( "/script.js", get(|| async { ( [(header::CONTENT_TYPE, "text/javascript; charset=utf-8")], include_str!("assets/script.js"), ) }), ) .route( "/robots.txt", get(|| async { ( [(header::CONTENT_TYPE, "text/plain; charset=utf-8")], include_str!("assets/robots.txt"), ) }), ) .route("/opensearch.xml", get(opensearch::route)) .route("/search", get(search::route)) .route("/autocomplete", get(autocomplete::route)); println!("Listening on {BIND_ADDRESS}"); let listener = tokio::net::TcpListener::bind(BIND_ADDRESS).await.unwrap(); axum::serve( listener, app.into_make_service_with_connect_info::(), ) .await .unwrap(); }