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 2893a9e commit d7b9634
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions volo-http/src/server/layer/client_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,16 @@ impl ClientIPConfig {
/// layer::{ClientIPConfig, ClientIPLayer},
/// route::{get, Router},
/// Server,
/// };
/// };///
///
/// use volo_http::server::layer::ClientIP;
///
/// async fn index() -> &'static str {
/// "Hello, World"
/// async fn handler(client_ip: ClientIP) -> String {
/// client_ip.unwrap().to_string()
/// }
///
/// let router: Router = Router::new()
/// .route("/", get(index))
/// .route("/", get(handler))
/// .layer(ClientIPLayer::default());
/// ```
///
Expand All @@ -198,8 +200,8 @@ impl ClientIPConfig {
/// },
/// };
///
/// async fn index() -> &'static str {
/// "Hello, World"
/// async fn handler(client_ip: ClientIP) -> String {
/// client_ip.unwrap().to_string()
/// }
///
/// fn client_ip_handler(
Expand All @@ -210,7 +212,7 @@ impl ClientIPConfig {
/// unimplemented!()
/// }
///
/// let router: Router = Router::new().route("/", get(index)).layer(
/// let router: Router = Router::new().route("/", get(handler)).layer(
/// ClientIPLayer::new(client_ip_handler).with_config(
/// ClientIPConfig::new()
/// .with_remote_ip_headers(vec!["x-real-ip", "x-forwarded-for"])
Expand Down

0 comments on commit d7b9634

Please sign in to comment.