diff --git a/core/lib/src/response/responder.rs b/core/lib/src/response/responder.rs index c3966d24..c6fbdd8b 100644 --- a/core/lib/src/response/responder.rs +++ b/core/lib/src/response/responder.rs @@ -106,8 +106,7 @@ use crate::request::Request; /// /// # Return Value /// -/// A `Responder` returns a `Future` whose output type is a `Result`. +/// A `Responder` returns a `Result`. /// /// * An `Ok(Response)` indicates success. The `Response` will be written out /// to the client. @@ -145,6 +144,14 @@ use crate::request::Request; /// _handler_ from its type signature also becomes more difficult. You should /// avoid varying responses based on the `Request` value as much as possible. /// +/// 4. Perform `async` I/O in Constructors +/// +/// The `Responder` trait is not an `async` trait. This is not an oversight. +/// Instead of performing `async` operations in what would be the +/// `respond_to` method, perform them in a constructor for the responder. As +/// an example, see [`NamedFile::open()`](crate::fs::NamedFile::open()), +/// which performs the requisite I/O for `NamedFile`'s responder. +/// /// ## Lifetimes /// /// `Responder` has two lifetimes: `Responder<'r, 'o: 'r>`.