1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-07-01 00:44:26 +02:00

clarify resource/scope app data overriding (#1476)

* relocate FnDataFactory

* clarify app data overriding in Scope and Resource

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
This commit is contained in:
Rob Ede
2020-04-29 18:20:47 +01:00
committed by GitHub
parent bb17280f51
commit c27d3fad8e
6 changed files with 191 additions and 108 deletions

View File

@ -151,9 +151,11 @@ where
self.app_data(Data::new(data))
}
/// Set or override application data.
/// Add scope data.
///
/// This method overrides data stored with [`App::app_data()`](#method.app_data)
/// If used, this method will create a new data context used for extracting
/// from requests. Data added here is *not* merged with data added on App
/// or containing scopes.
pub fn app_data<U: 'static>(mut self, data: U) -> Self {
if self.data.is_none() {
self.data = Some(Extensions::new());