cargo fmt
This commit is contained in:
parent
4eb510039c
commit
db24d0a497
11
src/main.rs
11
src/main.rs
|
@ -41,7 +41,9 @@ async fn try_update(state: &AppState, fetcher: &mut PdfFetcher) -> Result<(), Er
|
|||
}
|
||||
|
||||
async fn start_updater() -> Result<web::Data<AppState>, Error> {
|
||||
let cached_pdf_path = PathBuf::from(std::env::var("CACHED_PDF_PATH").unwrap_or_else(|_| String::from("data.pdf")));
|
||||
let cached_pdf_path = PathBuf::from(
|
||||
std::env::var("CACHED_PDF_PATH").unwrap_or_else(|_| String::from("data.pdf")),
|
||||
);
|
||||
let mut fetcher = PdfFetcher::new(cached_pdf_path)?;
|
||||
let state = web::Data::new(AppState {
|
||||
dataset: RwLock::new(Arc::new(load_data(&mut fetcher).await?)),
|
||||
|
@ -66,14 +68,17 @@ async fn start_updater() -> Result<web::Data<AppState>, Error> {
|
|||
async fn main() -> std::io::Result<()> {
|
||||
simple_logger::init_with_level(log::Level::Info).unwrap();
|
||||
|
||||
let static_dir = PathBuf::from(std::env::var("STATIC_DIR").unwrap_or_else(|_| String::from("static")));
|
||||
let static_dir =
|
||||
PathBuf::from(std::env::var("STATIC_DIR").unwrap_or_else(|_| String::from("static")));
|
||||
|
||||
let state = start_updater().await.expect("Failed to initialize state");
|
||||
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.app_data(state.clone())
|
||||
.wrap(Logger::new(r#"%{r}a "%r" %s %b "%{Referer}i" "%{User-Agent}i" %T"#))
|
||||
.wrap(Logger::new(
|
||||
r#"%{r}a "%r" %s %b "%{Referer}i" "%{User-Agent}i" %T"#,
|
||||
))
|
||||
.service(csv)
|
||||
.service(json)
|
||||
.service(actix_files::Files::new("/", static_dir.clone()).index_file("index.html"))
|
||||
|
|
Loading…
Reference in a new issue