Skip to content

Commit

Permalink
improve docs for app_config methods
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Feb 22, 2023
1 parent 42193be commit 358c1cf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
8 changes: 6 additions & 2 deletions actix-web/src/app_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -155,14 +155,15 @@ 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,
pool: HttpRequestPool,
}

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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion actix-web/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion actix-web/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 3 additions & 6 deletions actix-web/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 358c1cf

Please sign in to comment.