mirror of
https://github.com/actix/examples
synced 2025-06-28 09:50:36 +02:00
standardize examples
This commit is contained in:
@ -58,14 +58,15 @@ async fn index(
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_web=info");
|
||||
env_logger::init();
|
||||
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||
|
||||
// Create some global state prior to building the server
|
||||
#[allow(clippy::mutex_atomic)] // it's intentional.
|
||||
let counter_mutex = Data::new(Mutex::new(0usize));
|
||||
let counter_atomic = Data::new(AtomicUsize::new(0usize));
|
||||
|
||||
log::info!("starting HTTP server at http://localhost:8080");
|
||||
|
||||
// move is necessary to give closure below ownership of counter1
|
||||
HttpServer::new(move || {
|
||||
// Create some thread-local state
|
||||
|
Reference in New Issue
Block a user