1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-11 09:49:29 +00:00

Merge branch 'master' into scope_work

This commit is contained in:
Jonathan Lim 2023-10-11 23:13:46 -07:00 committed by GitHub
commit 03501cbf98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {
/// ... /// ...