1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-26 17:27:42 +02:00

remove fn state service

This commit is contained in:
Nikolay Kim
2018-09-19 08:04:31 -07:00
parent 601c8a4ee6
commit 4c422983ba
5 changed files with 18 additions and 177 deletions

View File

@ -47,14 +47,13 @@ fn main() {
// in this case, on success we use `logger` service
.and_then(logger)
// next service uses two components, service state and service function
// actix-net generates `NewService` impl that creates `ServiceState` instance for each new service
// and use `service` function as `Service::call`
.and_then((service, move || {
Ok(ServiceState { num: num.clone() })
}))
},
).unwrap()
// Next service counts number of connections
.and_then(move |req| {
let num = num.fetch_add(1, Ordering::Relaxed);
println!("processed {:?} connections", num);
future::ok(())
})
}).unwrap()
.start();
sys.run();