From 358c1cf85baa06b1c7b75795e6de06599b84f52b Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 22 Feb 2023 23:06:18 +0000 Subject: [PATCH] improve docs for app_config methods --- actix-web/src/app_service.rs | 8 ++++++-- actix-web/src/config.rs | 2 +- actix-web/src/request.rs | 2 +- actix-web/src/service.rs | 9 +++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/actix-web/src/app_service.rs b/actix-web/src/app_service.rs index 0b5ba2ab6..0fc856203 100644 --- a/actix-web/src/app_service.rs +++ b/actix-web/src/app_service.rs @@ -21,7 +21,7 @@ use crate::{ Error, HttpResponse, }; -/// Service factory to convert `Request` to a `ServiceRequest`. +/// Service factory to convert [`Request`] to a [`ServiceRequest`]. /// /// It also executes data factories. pub struct AppInit @@ -155,7 +155,7 @@ where app_state: Rc, } -/// 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, 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, config: AppConfig) -> Rc { 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 diff --git a/actix-web/src/config.rs b/actix-web/src/config.rs index 68bea34ca..11eaf8720 100644 --- a/actix-web/src/config.rs +++ b/actix-web/src/config.rs @@ -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 } diff --git a/actix-web/src/request.rs b/actix-web/src/request.rs index 6a32bf838..a99dcaa3e 100644 --- a/actix-web/src/request.rs +++ b/actix-web/src/request.rs @@ -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() diff --git a/actix-web/src/service.rs b/actix-web/src/service.rs index ea23f09f5..f7692ce16 100644 --- a/actix-web/src/service.rs +++ b/actix-web/src/service.rs @@ -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 { 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()