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

improve docs for app_config methods

This commit is contained in:
Rob Ede 2023-02-22 23:06:18 +00:00
parent 42193bee29
commit 358c1cf85b
No known key found for this signature in database
GPG key ID: 97C636207D3EF933
4 changed files with 11 additions and 10 deletions

View file

@ -21,7 +21,7 @@ use crate::{
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.
pub struct AppInit<T, B>
@ -155,7 +155,7 @@ where
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 {
rmap: Rc<ResourceMap>,
config: AppConfig,
@ -163,6 +163,7 @@ pub(crate) struct AppInitServiceState {
}
impl AppInitServiceState {
/// Constructs state collection from resource map and app config.
pub(crate) fn new(rmap: Rc<ResourceMap>, config: AppConfig) -> Rc<Self> {
Rc::new(AppInitServiceState {
rmap,
@ -171,16 +172,19 @@ impl AppInitServiceState {
})
}
/// Returns a reference to the application's resource map.
#[inline]
pub(crate) fn rmap(&self) -> &ResourceMap {
&self.rmap
}
/// Returns a reference to the application's configuration.
#[inline]
pub(crate) fn config(&self) -> &AppConfig {
&self.config
}
/// Returns a reference to the application's request pool.
#[inline]
pub(crate) fn pool(&self) -> &HttpRequestPool {
&self.pool

View file

@ -141,7 +141,7 @@ impl AppConfig {
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 {
self.addr
}

View file

@ -260,7 +260,7 @@ impl HttpRequest {
Ref::map(self.extensions(), |data| data.get().unwrap())
}
/// App config
/// Returns a reference to the application's connection configuration.
#[inline]
pub fn app_config(&self) -> &AppConfig {
self.app_state().config()

View file

@ -238,11 +238,7 @@ impl ServiceRequest {
self.req.connection_info()
}
/// Returns reference to the Path parameters.
///
/// 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.
/// Counterpart to [`HttpRequest::match_info`].
#[inline]
pub fn match_info(&self) -> &Path<Url> {
self.req.match_info()
@ -267,12 +263,13 @@ impl ServiceRequest {
}
/// Returns a reference to the application's resource map.
/// Counterpart to [`HttpRequest::resource_map`].
#[inline]
pub fn resource_map(&self) -> &ResourceMap {
self.req.resource_map()
}
/// Returns a reference to the application's configuration.
/// Counterpart to [`HttpRequest::app_config`].
#[inline]
pub fn app_config(&self) -> &AppConfig {
self.req.app_config()