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