mirror of
https://github.com/actix/actix-website
synced 2025-01-22 16:15:56 +01:00
Fix examples
This commit is contained in:
parent
31630f61f8
commit
77b86e778f
@ -1,5 +1,6 @@
|
||||
// <setup>
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use std::sync::{Mutex};
|
||||
|
||||
// This struct represents state
|
||||
struct AppState {
|
||||
@ -19,7 +20,7 @@ struct AppStateWithCounter {
|
||||
}
|
||||
|
||||
fn _index(data: web::Data<AppStateWithCounter>) -> String {
|
||||
let mut counter = state.counter.lock().unwrap(); // <- get counter's MutexGuard
|
||||
let mut counter = data.counter.lock().unwrap(); // <- get counter's MutexGuard
|
||||
*counter += 1; // <- access counter inside MutexGuard
|
||||
|
||||
format!("Request number: {}", counter) // <- response with count
|
||||
|
Loading…
x
Reference in New Issue
Block a user