1
0
mirror of https://github.com/actix/examples synced 2025-06-28 09:50:36 +02:00

update actix-web to 1.0.0

This commit is contained in:
Nikolay Kim
2019-06-06 16:47:40 +06:00
parent db86fdc3db
commit aa5750cafc
35 changed files with 69 additions and 69 deletions

View File

@ -6,6 +6,6 @@ workspace = ".."
edition = "2018"
[dependencies]
actix-web = "1.0.0-beta.4"
actix-web = "1.0.0"
futures = "0.1.25"
env_logger = "0.6"

View File

@ -12,12 +12,12 @@
//! Check [user guide](https://actix.rs/book/actix-web/sec-2-application.html) for more info.
use std::io;
use std::sync::{Arc, Mutex};
use std::sync::Mutex;
use actix_web::{middleware, web, App, HttpRequest, HttpResponse, HttpServer};
/// simple handle
fn index(state: web::Data<Arc<Mutex<usize>>>, req: HttpRequest) -> HttpResponse {
fn index(state: web::Data<Mutex<usize>>, req: HttpRequest) -> HttpResponse {
println!("{:?}", req);
*(state.lock().unwrap()) += 1;
@ -28,12 +28,12 @@ fn main() -> io::Result<()> {
std::env::set_var("RUST_LOG", "actix_web=info");
env_logger::init();
let counter = Arc::new(Mutex::new(0usize));
let counter = web::Data::new(Mutex::new(0usize));
//move is necessary to give closure below ownership of counter
HttpServer::new(move || {
App::new()
.data(counter.clone()) // <- create app with shared state
.register_data(counter.clone()) // <- create app with shared state
// enable logger
.wrap(middleware::Logger::default())
// register simple handler, handle all methods