Update src/types/form.rs

Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
This commit is contained in:
Arniu Tseng 2021-06-01 22:36:14 +08:00 committed by GitHub
parent 4fe14c2e7c
commit 4fa023f4d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -229,8 +229,9 @@ impl FormConfig {
self
}
/// Extract payload config from app data. Check both `T` and `Data<T>`, in that order, and fall
/// back to the default payload config.
/// Extract payload config from app data.
///
/// Checks both `T` and `Data<T>`, in that order, and falls back to the default payload config.
fn from_req(req: &HttpRequest) -> &Self {
req.app_data::<Self>()
.or_else(|| req.app_data::<web::Data<Self>>().map(|d| d.as_ref()))