mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 00:21:08 +01:00
update handler failure mode docs
This commit is contained in:
parent
fba766b4be
commit
05b4c4964f
@ -10,10 +10,12 @@ use crate::{
|
|||||||
/// The interface for request handlers.
|
/// The interface for request handlers.
|
||||||
///
|
///
|
||||||
/// # What Is A Request Handler
|
/// # What Is A Request Handler
|
||||||
|
///
|
||||||
/// In short, a handler is just an async function that receives request-based arguments, in any
|
/// In short, a handler is just an async function that receives request-based arguments, in any
|
||||||
/// order, and returns something that can be converted to a response.
|
/// order, and returns something that can be converted to a response.
|
||||||
///
|
///
|
||||||
/// In particular, a request handler has three requirements:
|
/// In particular, a request handler has three requirements:
|
||||||
|
///
|
||||||
/// 1. It is an async function (or a function/closure that returns an appropriate future);
|
/// 1. It is an async function (or a function/closure that returns an appropriate future);
|
||||||
/// 1. The function parameters (up to 12) implement [`FromRequest`];
|
/// 1. The function parameters (up to 12) implement [`FromRequest`];
|
||||||
/// 1. The async function (or future) resolves to a type that can be converted into an
|
/// 1. The async function (or future) resolves to a type that can be converted into an
|
||||||
@ -21,11 +23,15 @@ use crate::{
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
/// # Compiler Errors
|
/// # Compiler Errors
|
||||||
|
///
|
||||||
/// If you get the error `the trait Handler<_> is not implemented`, then your handler does not
|
/// If you get the error `the trait Handler<_> is not implemented`, then your handler does not
|
||||||
/// fulfill the _first_ of the above requirements. Missing other requirements manifest as errors on
|
/// fulfill the _first_ of the above requirements. (It could also mean that you're attempting to use
|
||||||
/// implementing [`FromRequest`] and [`Responder`], respectively.
|
/// a macro-routed handler in a manual routing context like `web::get().to(handler)`, which is not
|
||||||
|
/// supported). Breaking the other requirements manifests as errors on implementing [`FromRequest`]
|
||||||
|
/// and [`Responder`], respectively.
|
||||||
///
|
///
|
||||||
/// # How Do Handlers Receive Variable Numbers Of Arguments
|
/// # How Do Handlers Receive Variable Numbers Of Arguments
|
||||||
|
///
|
||||||
/// Rest assured there is no macro magic here; it's just traits.
|
/// Rest assured there is no macro magic here; it's just traits.
|
||||||
///
|
///
|
||||||
/// The first thing to note is that [`FromRequest`] is implemented for tuples (up to 12 in length).
|
/// The first thing to note is that [`FromRequest`] is implemented for tuples (up to 12 in length).
|
||||||
@ -40,6 +46,7 @@ use crate::{
|
|||||||
/// destructures the tuple into its component types and calls your handler function with them.
|
/// destructures the tuple into its component types and calls your handler function with them.
|
||||||
///
|
///
|
||||||
/// In pseudo-code the process looks something like this:
|
/// In pseudo-code the process looks something like this:
|
||||||
|
///
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// async fn my_handler(body: String, state: web::Data<MyState>) -> impl Responder {
|
/// async fn my_handler(body: String, state: web::Data<MyState>) -> impl Responder {
|
||||||
/// ...
|
/// ...
|
||||||
|
Loading…
Reference in New Issue
Block a user