upgrades actix to 1.0

This commit is contained in:
2019-06-19 14:06:38 +02:00
parent ed6a6a4a3f
commit f589751f8c
2 changed files with 15 additions and 15 deletions

View File

@@ -5,7 +5,8 @@ authors = ["Artus <artus@landoftheunicorn.ovh>"]
edition = "2018"
[dependencies]
actix-web = "0.7"
actix-web = "1.0.*"
actix-files = "*"
lootalot-db = { version = "0.1", path = "./lootalot_db" }
dotenv = "*"

View File

@@ -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()
}