mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-23 16:21:06 +01:00
improve docs for app_config methods
This commit is contained in:
parent
42193bee29
commit
358c1cf85b
@ -21,7 +21,7 @@ use crate::{
|
|||||||
Error, HttpResponse,
|
Error, HttpResponse,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Service factory to convert `Request` to a `ServiceRequest<S>`.
|
/// Service factory to convert [`Request`] to a [`ServiceRequest<S>`].
|
||||||
///
|
///
|
||||||
/// It also executes data factories.
|
/// It also executes data factories.
|
||||||
pub struct AppInit<T, B>
|
pub struct AppInit<T, B>
|
||||||
@ -155,7 +155,7 @@ where
|
|||||||
app_state: Rc<AppInitServiceState>,
|
app_state: Rc<AppInitServiceState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A collection of [`AppInitService`] state that shared across `HttpRequest`s.
|
/// A collection of state for [`AppInitService`] that is shared across [`HttpRequest`]s.
|
||||||
pub(crate) struct AppInitServiceState {
|
pub(crate) struct AppInitServiceState {
|
||||||
rmap: Rc<ResourceMap>,
|
rmap: Rc<ResourceMap>,
|
||||||
config: AppConfig,
|
config: AppConfig,
|
||||||
@ -163,6 +163,7 @@ pub(crate) struct AppInitServiceState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AppInitServiceState {
|
impl AppInitServiceState {
|
||||||
|
/// Constructs state collection from resource map and app config.
|
||||||
pub(crate) fn new(rmap: Rc<ResourceMap>, config: AppConfig) -> Rc<Self> {
|
pub(crate) fn new(rmap: Rc<ResourceMap>, config: AppConfig) -> Rc<Self> {
|
||||||
Rc::new(AppInitServiceState {
|
Rc::new(AppInitServiceState {
|
||||||
rmap,
|
rmap,
|
||||||
@ -171,16 +172,19 @@ impl AppInitServiceState {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a reference to the application's resource map.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn rmap(&self) -> &ResourceMap {
|
pub(crate) fn rmap(&self) -> &ResourceMap {
|
||||||
&self.rmap
|
&self.rmap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a reference to the application's configuration.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn config(&self) -> &AppConfig {
|
pub(crate) fn config(&self) -> &AppConfig {
|
||||||
&self.config
|
&self.config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a reference to the application's request pool.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn pool(&self) -> &HttpRequestPool {
|
pub(crate) fn pool(&self) -> &HttpRequestPool {
|
||||||
&self.pool
|
&self.pool
|
||||||
|
@ -141,7 +141,7 @@ impl AppConfig {
|
|||||||
self.secure
|
self.secure
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the socket address of the local half of this TCP connection
|
/// Returns the socket address of the local half of this TCP connection.
|
||||||
pub fn local_addr(&self) -> SocketAddr {
|
pub fn local_addr(&self) -> SocketAddr {
|
||||||
self.addr
|
self.addr
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ impl HttpRequest {
|
|||||||
Ref::map(self.extensions(), |data| data.get().unwrap())
|
Ref::map(self.extensions(), |data| data.get().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// App config
|
/// Returns a reference to the application's connection configuration.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn app_config(&self) -> &AppConfig {
|
pub fn app_config(&self) -> &AppConfig {
|
||||||
self.app_state().config()
|
self.app_state().config()
|
||||||
|
@ -238,11 +238,7 @@ impl ServiceRequest {
|
|||||||
self.req.connection_info()
|
self.req.connection_info()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns reference to the Path parameters.
|
/// Counterpart to [`HttpRequest::match_info`].
|
||||||
///
|
|
||||||
/// Params is a container for URL parameters. A variable segment is specified in the form
|
|
||||||
/// `{identifier}`, where the identifier can be used later in a request handler to access the
|
|
||||||
/// matched value for that segment.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn match_info(&self) -> &Path<Url> {
|
pub fn match_info(&self) -> &Path<Url> {
|
||||||
self.req.match_info()
|
self.req.match_info()
|
||||||
@ -267,12 +263,13 @@ impl ServiceRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to the application's resource map.
|
/// Returns a reference to the application's resource map.
|
||||||
|
/// Counterpart to [`HttpRequest::resource_map`].
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn resource_map(&self) -> &ResourceMap {
|
pub fn resource_map(&self) -> &ResourceMap {
|
||||||
self.req.resource_map()
|
self.req.resource_map()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to the application's configuration.
|
/// Counterpart to [`HttpRequest::app_config`].
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn app_config(&self) -> &AppConfig {
|
pub fn app_config(&self) -> &AppConfig {
|
||||||
self.req.app_config()
|
self.req.app_config()
|
||||||
|
Loading…
Reference in New Issue
Block a user