From f589751f8c324d89a52a02f5335781c3f8d4aa88 Mon Sep 17 00:00:00 2001 From: Artus Date: Wed, 19 Jun 2019 14:06:38 +0200 Subject: [PATCH] upgrades actix to 1.0 --- Cargo.toml | 3 ++- src/main.rs | 27 +++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d9ed1af..5d198fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,8 @@ authors = ["Artus "] edition = "2018" [dependencies] -actix-web = "0.7" +actix-web = "1.0.*" +actix-files = "*" lootalot-db = { version = "0.1", path = "./lootalot_db" } dotenv = "*" diff --git a/src/main.rs b/src/main.rs index a146bdc..b7870ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,12 +2,13 @@ extern crate actix_web; extern crate dotenv; extern crate lootalot_db; -use actix_web::{fs, server, App, HttpRequest, Result}; +use actix_files as fs; +use actix_web::{HttpServer, App, web::Json}; use std::env; mod api { - use actix_web::{Result, Json}; + use actix_web::{ Result, web::Json}; struct Player; struct Item; @@ -37,22 +38,20 @@ mod api { } -fn main() { +fn main() -> std::io::Result<()> { println!("Hello, world!"); dotenv::dotenv().ok(); let www_root: String = env::var("WWW_ROOT").expect("WWW_ROOT must be set"); println!("serving files from: {}", &www_root); - server::new(move || { - App::new().handler( - "/", - fs::StaticFiles::new(www_root.clone()) - .unwrap() - .index_file("index.html"), - ) - }) - .bind("127.0.0.1:8088") - .unwrap() - .run(); + HttpServer::new(move || { + App::new() + .service( + fs::Files::new("/", www_root.clone()) + .index_file("index.html") + ) + }) + .bind("127.0.0.1:8088")? + .run() }