mirror of
https://github.com/actix/examples
synced 2025-06-28 18:00:37 +02:00
upgrade to 2.0 alpha.3
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
[package]
|
||||
name = "state"
|
||||
version = "0.1.0"
|
||||
version = "2.0.0"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
workspace = ".."
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "1.0.0"
|
||||
futures = "0.1.25"
|
||||
actix-web = "2.0.0-alpha.3"
|
||||
actix-rt = "1.0.0-alpha.3"
|
||||
futures = "0.3.1"
|
||||
env_logger = "0.6"
|
||||
|
@ -17,14 +17,15 @@ use std::sync::Mutex;
|
||||
use actix_web::{middleware, web, App, HttpRequest, HttpResponse, HttpServer};
|
||||
|
||||
/// simple handle
|
||||
fn index(state: web::Data<Mutex<usize>>, req: HttpRequest) -> HttpResponse {
|
||||
async fn index(state: web::Data<Mutex<usize>>, req: HttpRequest) -> HttpResponse {
|
||||
println!("{:?}", req);
|
||||
*(state.lock().unwrap()) += 1;
|
||||
|
||||
HttpResponse::Ok().body(format!("Num of requests: {}", state.lock().unwrap()))
|
||||
}
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
#[actix_rt::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
|
||||
@ -40,5 +41,6 @@ fn main() -> io::Result<()> {
|
||||
.service(web::resource("/").to(index))
|
||||
})
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.start()
|
||||
.await
|
||||
}
|
||||
|
Reference in New Issue
Block a user