mirror of https://github.com/rwf2/Rocket.git
parent
9c052be2dc
commit
372e9671eb
|
@ -106,8 +106,7 @@ use crate::request::Request;
|
|||
///
|
||||
/// # Return Value
|
||||
///
|
||||
/// A `Responder` returns a `Future` whose output type is a `Result<Response,
|
||||
/// Status>`.
|
||||
/// A `Responder` returns a `Result<Response, Status>`.
|
||||
///
|
||||
/// * 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>`.
|
||||
|
|
Loading…
Reference in New Issue