upgrades actix to 1.0
This commit is contained in:
@@ -5,7 +5,8 @@ authors = ["Artus <artus@landoftheunicorn.ovh>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "0.7"
|
actix-web = "1.0.*"
|
||||||
|
actix-files = "*"
|
||||||
lootalot-db = { version = "0.1", path = "./lootalot_db" }
|
lootalot-db = { version = "0.1", path = "./lootalot_db" }
|
||||||
dotenv = "*"
|
dotenv = "*"
|
||||||
|
|
||||||
|
|||||||
23
src/main.rs
23
src/main.rs
@@ -2,12 +2,13 @@ extern crate actix_web;
|
|||||||
extern crate dotenv;
|
extern crate dotenv;
|
||||||
extern crate lootalot_db;
|
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;
|
use std::env;
|
||||||
|
|
||||||
|
|
||||||
mod api {
|
mod api {
|
||||||
use actix_web::{Result, Json};
|
use actix_web::{ Result, web::Json};
|
||||||
|
|
||||||
struct Player;
|
struct Player;
|
||||||
struct Item;
|
struct Item;
|
||||||
@@ -37,22 +38,20 @@ mod api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() -> std::io::Result<()> {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
|
|
||||||
let www_root: String = env::var("WWW_ROOT").expect("WWW_ROOT must be set");
|
let www_root: String = env::var("WWW_ROOT").expect("WWW_ROOT must be set");
|
||||||
println!("serving files from: {}", &www_root);
|
println!("serving files from: {}", &www_root);
|
||||||
server::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new().handler(
|
App::new()
|
||||||
"/",
|
.service(
|
||||||
fs::StaticFiles::new(www_root.clone())
|
fs::Files::new("/", www_root.clone())
|
||||||
.unwrap()
|
.index_file("index.html")
|
||||||
.index_file("index.html"),
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
.run()
|
||||||
.run();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user