Skip to content

Commit

Permalink
Grammatical fixes in docstrings (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitfl0wer authored Sep 1, 2024
1 parent c5154cd commit 21b8301
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 49 deletions.
4 changes: 2 additions & 2 deletions poem/src/middleware/add_data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{Endpoint, Middleware, Request, Result};

/// Middleware for add any data to request.
/// Middleware for adding any data to a request.
pub struct AddData<T> {
value: T,
}
Expand All @@ -27,7 +27,7 @@ where
}
}

/// Endpoint for AddData middleware.
/// Endpoint for the AddData middleware.
pub struct AddDataEndpoint<E, T> {
inner: E,
value: T,
Expand Down
4 changes: 2 additions & 2 deletions poem/src/middleware/catch_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ where
}
}

/// Middleware for catches panics and converts them into `500 INTERNAL SERVER
/// Middleware that catches panics and converts them into `500 INTERNAL SERVER
/// ERROR` responses.
///
/// # Example
Expand Down Expand Up @@ -122,7 +122,7 @@ impl<E: Endpoint, H: PanicHandler> Middleware<E> for CatchPanic<H> {
}
}

/// Endpoint for `PanicHandler` middleware.
/// Endpoint for the `PanicHandler` middleware.
pub struct CatchPanicEndpoint<E, H> {
inner: E,
panic_handler: H,
Expand Down
11 changes: 5 additions & 6 deletions poem/src/middleware/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@ fn parse_accept_encoding(
.map(|(coding, _)| coding)
}

/// Middleware for decompress request body and compress response body.
/// Middleware to decompress the request body and compress the response body.
///
/// It selects the decompression algorithm according to the request
/// `Content-Encoding` header, and selects the compression algorithm according
/// to the request `Accept-Encoding` header.
/// The decompression algorithm is selected according to the request `Content-Encoding` header,
/// and the compression algorithm is selected according to the request `Accept-Encoding` header.
#[cfg_attr(docsrs, doc(cfg(feature = "compression")))]
#[derive(Default)]
pub struct Compression {
Expand All @@ -97,7 +96,7 @@ impl Compression {
}
}

/// Specify the enabled algorithms (default to all)
/// Specify the enabled algorithms (defaults to all)
#[must_use]
#[inline]
pub fn algorithms(self, algorithms: impl IntoIterator<Item = CompressionAlgo>) -> Self {
Expand All @@ -120,7 +119,7 @@ impl<E: Endpoint> Middleware<E> for Compression {
}
}

/// Endpoint for Compression middleware.
/// Endpoint for the Compression middleware.
#[cfg_attr(docsrs, doc(cfg(feature = "compression")))]
pub struct CompressionEndpoint<E: Endpoint> {
ep: E,
Expand Down
2 changes: 1 addition & 1 deletion poem/src/middleware/cookie_jar_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ where
}
}

/// Endpoint for `CookieJarManager` middleware.
/// Endpoint for the `CookieJarManager` middleware.
#[cfg_attr(docsrs, doc(cfg(feature = "cookie")))]
pub struct CookieJarManagerEndpoint<E> {
inner: E,
Expand Down
8 changes: 4 additions & 4 deletions poem/src/middleware/cors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl Cors {
}
}

/// Set allow credentials.
/// Set the allow credentials.
#[must_use]
pub fn allow_credentials(mut self, allow_credentials: bool) -> Self {
self.allow_credentials = allow_credentials;
Expand All @@ -67,7 +67,7 @@ impl Cors {

/// Add an allow header.
///
/// NOTE: Default is allow any header.
/// NOTE: The default is to allow any header.
#[must_use]
pub fn allow_header<T>(mut self, header: T) -> Self
where
Expand Down Expand Up @@ -95,7 +95,7 @@ impl Cors {

/// Add an allow method.
///
/// NOTE: Default is allow any method.
/// NOTE: The default is to allow any method.
#[must_use]
pub fn allow_method<T>(mut self, method: T) -> Self
where
Expand Down Expand Up @@ -123,7 +123,7 @@ impl Cors {

/// Add an allow origin.
///
/// NOTE: Default is allow any origin.
/// NOTE: The default is to allow any origin.
#[must_use]
pub fn allow_origin<T>(mut self, origin: T) -> Self
where
Expand Down
8 changes: 4 additions & 4 deletions poem/src/middleware/csrf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Csrf {
Self { key, ..self }
}

/// Sets the `Secure` to the csrf cookie. Default is `true`.
/// Sets, whether `Secure` is set for the csrf cookie. Defaults to `true`.
#[must_use]
pub fn secure(self, value: bool) -> Self {
Self {
Expand All @@ -128,7 +128,7 @@ impl Csrf {
}
}

/// Sets the `HttpOnly` to the csrf cookie. Default is `true`.
/// Sets, whether `HttpOnly` is set for the csrf cookie. Defaults to `true`.
#[must_use]
pub fn http_only(self, value: bool) -> Self {
Self {
Expand All @@ -137,7 +137,7 @@ impl Csrf {
}
}

/// Sets the `SameSite` to the csrf cookie. Default is
/// Sets, whether `SameSite` is set for the csrf cookie. Defaults to `true`.
/// [`SameSite::Strict`](libcookie::SameSite::Strict).
#[must_use]
pub fn same_site(self, value: impl Into<Option<SameSite>>) -> Self {
Expand Down Expand Up @@ -174,7 +174,7 @@ impl<E: Endpoint> Middleware<E> for Csrf {
}
}

/// Endpoint for Csrf middleware.
/// Endpoint for the Csrf middleware.
#[cfg_attr(docsrs, doc(cfg(feature = "csrf")))]
pub struct CsrfEndpoint<E> {
inner: E,
Expand Down
8 changes: 4 additions & 4 deletions poem/src/middleware/force_https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ use crate::{web::Redirect, Endpoint, IntoResponse, Middleware, Request, Response

type FilterFn = Arc<dyn Fn(&Request) -> bool + Send + Sync>;

/// Middleware for force redirect to HTTPS uri.
/// Middleware which forces redirects to a HTTPS uri.
#[derive(Default)]
pub struct ForceHttps {
https_port: Option<u16>,
filter_fn: Option<FilterFn>,
}

impl ForceHttps {
/// Create new `ForceHttps` middleware.
/// Create a new `ForceHttps` middleware.
pub fn new() -> Self {
Default::default()
}

/// Specify https port.
/// Specify the https port.
#[must_use]
pub fn https_port(self, port: u16) -> Self {
Self {
Expand Down Expand Up @@ -53,7 +53,7 @@ where
}
}

/// Endpoint for ForceHttps middleware.
/// Endpoint for the ForceHttps middleware.
pub struct ForceHttpsEndpoint<E> {
inner: E,
https_port: Option<u16>,
Expand Down
4 changes: 2 additions & 2 deletions poem/src/middleware/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ use crate::endpoint::Endpoint;

/// Represents a middleware trait.
///
/// # Create you own middleware
/// # Create your own middleware
///
/// ```
/// use poem::{
/// handler, test::TestClient, web::Data, Endpoint, EndpointExt, Middleware, Request, Result,
/// };
///
/// /// A middleware that extract token from HTTP headers.
/// /// A middleware that extracts token from HTTP headers.
/// struct TokenMiddleware;
///
/// impl<E: Endpoint> Middleware<E> for TokenMiddleware {
Expand Down
2 changes: 1 addition & 1 deletion poem/src/middleware/normalize_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<E: Endpoint> Middleware<E> for NormalizePath {
}
}

/// Endpoint for NormalizePath middleware.
/// Endpoint for the NormalizePath middleware.
pub struct NormalizePathEndpoint<E> {
inner: E,
merge_slash: Regex,
Expand Down
2 changes: 1 addition & 1 deletion poem/src/middleware/opentelemetry_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl<E: Endpoint> Middleware<E> for OpenTelemetryMetrics {
}
}

/// Endpoint for OpenTelemetryMetrics middleware.
/// Endpoint for the OpenTelemetryMetrics middleware.
#[cfg_attr(docsrs, doc(cfg(feature = "opentelemetry")))]
pub struct OpenTelemetryMetricsEndpoint<E> {
request_count: Counter<u64>,
Expand Down
2 changes: 1 addition & 1 deletion poem/src/middleware/opentelemetry_tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ where
}
}

/// Endpoint for `OpenTelemetryTracing` middleware.
/// Endpoint for the `OpenTelemetryTracing` middleware.
#[cfg_attr(docsrs, doc(cfg(feature = "opentelemetry")))]
pub struct OpenTelemetryTracingEndpoint<T, E> {
tracer: Arc<T>,
Expand Down
4 changes: 2 additions & 2 deletions poem/src/middleware/propagate_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use http::{header::HeaderName, HeaderMap};

use crate::{Endpoint, IntoResponse, Middleware, Request, Response, Result};

/// Middleware for propagate a header from the request to the response.
/// Middleware to propagate a header from the request to the response.
#[derive(Default)]
pub struct PropagateHeader {
headers: HashSet<HeaderName>,
Expand Down Expand Up @@ -41,7 +41,7 @@ impl<E: Endpoint> Middleware<E> for PropagateHeader {
}
}

/// Endpoint for PropagateHeader middleware.
/// Endpoint for the PropagateHeader middleware.
pub struct PropagateHeaderEndpoint<E> {
inner: E,
headers: HashSet<HeaderName>,
Expand Down
8 changes: 4 additions & 4 deletions poem/src/middleware/requestid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{

const X_REQUEST_ID: &str = "x-request-id";

/// Weather to use the request ID supplied in the request.
/// Whether to use the request ID supplied in the request.
#[derive(Clone, Copy, PartialEq, Eq, Default)]
#[cfg_attr(docsrs, doc(cfg(feature = "requestid")))]
pub enum ReuseId {
Expand Down Expand Up @@ -42,7 +42,7 @@ impl RequestId {
}
}

/// Configure weather to use the incoming ID.
/// Configure whether to use the incoming ID.
#[must_use]
pub fn reuse_id(self, reuse_id: ReuseId) -> Self {
Self {
Expand Down Expand Up @@ -72,7 +72,7 @@ impl<E: Endpoint> Middleware<E> for RequestId {
}
}

/// Endpoint for `RequestId` middleware.
/// Endpoint for the `RequestId` middleware.
#[cfg_attr(docsrs, doc(cfg(feature = "requestid")))]
pub struct RequestIdEndpoint<E> {
next: E,
Expand Down Expand Up @@ -103,7 +103,7 @@ impl<E: Endpoint> Endpoint for RequestIdEndpoint<E> {
}
}

/// A request ID that can be extracted in handler functions.
/// A request ID which can be extracted in handler functions.
#[cfg_attr(docsrs, doc(cfg(feature = "requestid")))]
#[derive(Clone)]
pub struct ReqId(String);
Expand Down
4 changes: 2 additions & 2 deletions poem/src/middleware/sensitive_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum AppliedTo {
Both,
}

/// Middleware for mark headers value represents sensitive information.
/// Middleware to mark that a headers' value represents sensitive information.
///
/// Sensitive data could represent passwords or other data that should not be
/// stored on disk or in memory. By marking header values as sensitive,
Expand Down Expand Up @@ -84,7 +84,7 @@ impl<E: Endpoint> Middleware<E> for SensitiveHeader {
}
}

/// Endpoint for SensitiveHeader middleware.
/// Endpoint for the SensitiveHeader middleware.
pub struct SensitiveHeaderEndpoint<E> {
inner: E,
headers: HashSet<HeaderName>,
Expand Down
12 changes: 6 additions & 6 deletions poem/src/middleware/set_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum Action {
Append(HeaderName, HeaderValue),
}

/// Middleware for override/append headers to response.
/// Middleware to override or append headers to a response.
///
/// # Example
///
Expand Down Expand Up @@ -54,10 +54,10 @@ impl SetHeader {
Default::default()
}

/// Inserts a header to response.
/// Inserts a header into the response.
///
/// If a previous value exists for the same header, it is
/// removed and replaced with the new header value.
/// If a previous value exists for the same header, it will
/// be overridden.
#[must_use]
pub fn overriding<K, V>(mut self, key: K, value: V) -> Self
where
Expand All @@ -72,7 +72,7 @@ impl SetHeader {
self
}

/// Appends a header to response.
/// Appends a header to the response.
///
/// If previous values exist, the header will have multiple values.
#[must_use]
Expand Down Expand Up @@ -101,7 +101,7 @@ impl<E: Endpoint> Middleware<E> for SetHeader {
}
}

/// Endpoint for SetHeader middleware.
/// Endpoint for the SetHeader middleware.
pub struct SetHeaderEndpoint<E> {
inner: E,
actions: Vec<Action>,
Expand Down
8 changes: 4 additions & 4 deletions poem/src/middleware/size_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::{
error::SizedLimitError, web::headers::HeaderMapExt, Endpoint, Middleware, Request, Result,
};

/// Middleware for limit the request payload size.
/// Middleware to limit the request payload size.
///
/// If the incoming request does not contain the `Content-Length` header, it
/// will return `LENGTH_REQUIRED` status code.
/// If the incoming request does not contain the `Content-Length` header, the
/// middleware will return the `LENGTH_REQUIRED` status code.
///
/// # Errors
///
Expand All @@ -32,7 +32,7 @@ impl<E: Endpoint> Middleware<E> for SizeLimit {
}
}

/// Endpoint for SizeLimit middleware.
/// Endpoint for the SizeLimit middleware.
pub struct SizeLimitEndpoint<E> {
inner: E,
max_size: usize,
Expand Down
2 changes: 1 addition & 1 deletion poem/src/middleware/tokio_metrics_mw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<E: Endpoint> Middleware<E> for TokioMetrics {
}
}

/// Endpoint for TokioMetrics middleware.
/// Endpoint for the TokioMetrics middleware.
pub struct TokioMetricsEndpoint<E> {
inner: E,
monitor: TaskMonitor,
Expand Down
2 changes: 1 addition & 1 deletion poem/src/middleware/tower_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ where
}
}

/// An endpoint to tower service adapter.
/// An endpoint to the tower service adapter.
pub struct EndpointToTowerService<E>(Arc<E>);

impl<E> Service<Request> for EndpointToTowerService<E>
Expand Down
2 changes: 1 addition & 1 deletion poem/src/middleware/tracing_mw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl<E: Endpoint> Middleware<E> for Tracing {
}
}

/// Endpoint for `Tracing` middleware.
/// Endpoint for the `Tracing` middleware.
pub struct TracingEndpoint<E> {
inner: E,
}
Expand Down

0 comments on commit 21b8301

Please sign in to comment.