Skip to content

Commit

Permalink
feat(http): add client ip
Browse files Browse the repository at this point in the history
  • Loading branch information
StellarisW committed Nov 18, 2024
1 parent 269df72 commit 3bb42fc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion volo-http/src/server/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
context::ServerContext,
error::server::{body_collection_error, ExtractBodyError},
request::{Request, RequestPartsExt},
server::layer::ClientIP,
server::utils::client_ip::ClientIP,
utils::macros::impl_deref_and_deref_mut,
};

Expand Down
2 changes: 0 additions & 2 deletions volo-http/src/server/layer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//! Collections of some useful `Layer`s.

mod body_limit;
mod client_ip;
mod filter;
mod timeout;

pub use body_limit::BodyLimitLayer;
pub use client_ip::{ClientIP, ClientIPConfig, ClientIPLayer};
pub use filter::FilterLayer;
pub use timeout::TimeoutLayer;
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl ClientIPConfig {
/// # Example
///
/// ```rust
/// use volo_http::server::layer::ClientIPConfig;
/// use volo_http::server::utils::client_ip::ClientIPConfig;
///
/// let client_ip_config =
/// ClientIPConfig::new().with_remote_ip_headers(vec!["X-Real-IP", "X-Forwarded-For"]);
Expand Down Expand Up @@ -110,7 +110,7 @@ impl ClientIPConfig {
/// # Example
///
/// ```rust
/// use volo_http::server::layer::ClientIPConfig;
/// use volo_http::server::utils::client_ip::ClientIPConfig;
///
/// let client_ip_config = ClientIPConfig::new()
/// .with_trusted_cidrs(vec!["0.0.0.0/0".parse().unwrap(), "::/0".parse().unwrap()]);
Expand Down Expand Up @@ -145,10 +145,10 @@ impl ClientIPConfig {
///
/// ```rust
/// ///
/// use volo_http::server::layer::ClientIP;
/// use volo_http::server::utils::client_ip::ClientIP;
/// use volo_http::server::{
/// layer::{ClientIPConfig, ClientIPLayer},
/// route::{get, Router},
/// utils::client_ip::{ClientIPConfig, ClientIPLayer},
/// Server,
/// };
///
Expand All @@ -168,8 +168,8 @@ impl ClientIPConfig {
/// use volo_http::{
/// context::ServerContext,
/// server::{
/// layer::{ClientIP, ClientIPConfig, ClientIPLayer},
/// route::{get, Router},
/// utils::client_ip::{ClientIP, ClientIPConfig, ClientIPLayer},
/// Server,
/// },
/// };
Expand Down Expand Up @@ -275,8 +275,8 @@ mod client_ip_tests {
body::BodyConversion,
context::ServerContext,
server::{
layer::{client_ip::ClientIPLayer, ClientIP, ClientIPConfig},
route::{get, Route},
utils::client_ip::{ClientIP, ClientIPConfig, ClientIPLayer},
},
utils::test_helpers::simple_req,
};
Expand Down
1 change: 1 addition & 0 deletions volo-http/src/server/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod serve_dir;

pub use file_response::FileResponse;
pub use serve_dir::ServeDir;
pub mod client_ip;

Check failure on line 8 in volo-http/src/server/utils/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

missing documentation for a module

error: missing documentation for a module --> volo-http/src/server/utils/mod.rs:8:1 | 8 | pub mod client_ip; | ^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> volo-http/src/lib.rs:6:9 | 6 | #![deny(missing_docs)] | ^^^^^^^^^^^^
#[cfg(feature = "multipart")]
pub mod multipart;
#[cfg(feature = "ws")]
Expand Down

0 comments on commit 3bb42fc

Please sign in to comment.