docs(service): add example of impl Service (#2209)
Add `examples/service_struct_impl.rs`, which provides an up-to-date example of implementing MakeService and Service on custom types. The `Svc` struct has a Counter, which demonstrates how to instantiate shared resources in the `MakeSvc` and pass the resource to the services. Updates the `examples/README.md` and the doc in `src/service/mod.rs`. Closes #1691
This commit is contained in:
@@ -21,8 +21,9 @@
|
||||
//! to a single connection. It defines how to respond to **all** requests that
|
||||
//! connection will receive.
|
||||
//!
|
||||
//! While it's possible to implement `Service` for a type manually, the helper
|
||||
//! [`service_fn`](service_fn) should be sufficient for most cases.
|
||||
//! The helper [`service_fn`](service_fn) should be sufficient for most cases, but
|
||||
//! if you need to implement `Service` for a type manually, you can follow the example
|
||||
//! in `service_struct_impl.rs`.
|
||||
//!
|
||||
//! # MakeService
|
||||
//!
|
||||
|
||||
Reference in New Issue
Block a user