Skip to content

Commit

Permalink
populate more doc sessions. (#924)
Browse files Browse the repository at this point in the history
* populate more doc sessions.

* more doc.
  • Loading branch information
fakeshadow authored Feb 6, 2024
1 parent f325ba3 commit 25ab9fa
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
1 change: 1 addition & 0 deletions web/src/middleware/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::service::Service;
/// # Type mutation
/// `Compress` would mutate response body type from `B` to `Coder<B>`. Service enclosed
/// by it must be able to handle it's mutation or utilize [TypeEraser] to erase the mutation.
/// For more explanation please reference [type mutation](crate::middleware#type-mutation).
///
/// [WebRequest]: crate::http::WebRequest
/// [WebResponse]: crate::http::WebResponse
Expand Down
1 change: 1 addition & 0 deletions web/src/middleware/decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::service::Service;
/// # Type mutation
/// `Decompress` would mutate request body type from `B` to `Coder<B>`. Service enclosed
/// by it must be able to handle it's mutation or utilize [TypeEraser] to erase the mutation.
/// For more explanation please reference [type mutation](crate::middleware#type-mutation).
///
/// [WebContext]: crate::WebContext
/// [TypeEraser]: crate::middleware::eraser::TypeEraser
Expand Down
7 changes: 4 additions & 3 deletions web/src/middleware/limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ use crate::{
/// General purposed limitation middleware. Limiting request/response body size etc.
///
/// # Type mutation
/// `Limit` would mutate request body type from `B` to `Limit<B>`. Service enclosed
/// by it must be able to handle it's mutation or utilize [TypeEraser] to erase the mutation.
/// [`Limit`] would mutate request body type from `B` to [`Limit<B>`]. Service enclosed by it must be
/// able to handle it's mutation or utilize [`TypeEraser`] to erase the mutation.
/// For more explanation please reference [`type mutation`](crate::middleware#type-mutation).
///
/// [TypeEraser]: crate::middleware::eraser::TypeEraser
/// [`TypeEraser`]: crate::middleware::eraser::TypeEraser
#[derive(Copy, Clone)]
pub struct Limit {
request_body_size: usize,
Expand Down
33 changes: 24 additions & 9 deletions web/src/middleware/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! middleware types.
//!
//! Middleware in xitca-web is powered by [Service] and [ServiceExt] trait.
//! [Service] trait provides logic for building and execute middleware.
//! [ServiceExt] trait provides combinator methods of applying middleware.
//! Middleware in xitca-web is powered by [`Service`] and [`ServiceExt`] trait.
//! [`Service`] trait provides logic for building and execute middleware.
//! [`ServiceExt`] trait provides combinator methods of applying middleware.
//!
//! # Quick start
//! ```rust
Expand Down Expand Up @@ -110,7 +110,7 @@
//! # todo!()
//! # }
//! ```
//! For detailed explanation of application state please reference [App::with_state]
//! For detailed explanation of application state please reference [`App::with_state`]
//!
//! ## Generic type for http body
//! ```rust
Expand Down Expand Up @@ -143,7 +143,7 @@
//! # todo!()
//! # }
//! ```
//! For http body type mutation please reference the `Type Mutation` part below.
//! For http body type mutation please reference the [`Type Mutation`](#type-mutation) part below.
//!
//! # Variants
//! ## async function as middleware
Expand Down Expand Up @@ -273,10 +273,25 @@
//! - `enclosed` and `enclosed_fn` share the same ordering rule however they are mixed in usage
//!
//! # Type mutation
//!
//! [App::with_state]: crate::App::with_state
//! [Service]: crate::service::Service
//! [ServiceExt]: crate::service::ServiceExt
//! - In [`WebContext<'_, C, B>`] type the last generic type param `B` is for http body type.
//! middleware and service are free to transform it's type and constraint it's inner/next service
//! to accept the new type as it's request http body type. [`DeCompress`] and [`Limit`] middleware are
//! examples of this practice. [`TypeEraser`] middleware on the other hand can be used to reserve the
//! type mutation and restore `B` type to it's default as [`RequestBody`] type. In this case web context
//! can be written in short form as [`WebContext<'_, C>`].
//! - [`WebResponse<B>`] type share the characteristic as web context type. The `B` type can be transform
//! into new type by services and middleware while type eraser is able to reverse the process.
//!
//! [`App::with_state`]: crate::App::with_state
//! [`Service`]: crate::service::Service
//! [`ServiceExt`]: crate::service::ServiceExt
//! [`WebContext<'_, C, B>`]: crate::WebContext
//! [`WebContext<'_, C>`]: crate::WebContext
//! [`Decompress`]: crate::middleware::decompress::Decompress
//! [`Limit`]: crate::middleware::limit::Limit
//! [`TypeEraser`]: crate::middleware::eraser::TypeEraser
//! [`RequestBody`]: crate::body::RequestBody
//! [`WebResponse<B>`]: crate::http::WebResponse
#[cfg(any(feature = "compress-br", feature = "compress-gz", feature = "compress-de"))]
pub mod compress;
Expand Down

0 comments on commit 25ab9fa

Please sign in to comment.