| 1 | //! Asynchronous Services |
| 2 | //! |
| 3 | //! A [`Service`] is a trait representing an asynchronous |
| 4 | //! function of a request to a response. It's similar to |
| 5 | //! `async fn(Request) -> Result<Response, Error>`. |
| 6 | //! |
| 7 | //! The argument and return value isn't strictly required to be for HTTP. |
| 8 | //! Therefore, hyper uses several "trait aliases" to reduce clutter around |
| 9 | //! bounds. These are: |
| 10 | //! |
| 11 | //! - `HttpService`: This is blanketly implemented for all types that |
| 12 | //! implement `Service<http::Request<B1>, Response = http::Response<B2>>`. |
| 13 | //! |
| 14 | //! # HttpService |
| 15 | //! |
| 16 | //! In hyper, especially in the server setting, a `Service` is usually bound |
| 17 | //! to a single connection. It defines how to respond to **all** requests that |
| 18 | //! connection will receive. |
| 19 | //! |
| 20 | //! The helper [`service_fn`] should be sufficient for most cases, but |
| 21 | //! if you need to implement `Service` for a type manually, you can follow the example |
| 22 | //! in `service_struct_impl.rs`. |
| 23 | |
| 24 | mod http; |
| 25 | mod service; |
| 26 | mod util; |
| 27 | |
| 28 | pub use self::http::HttpService; |
| 29 | pub use self::service::Service; |
| 30 | pub use self::util::service_fn; |
| 31 | |