Skip to content

Commit

Permalink
test: add cf client IP doc example
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Sep 14, 2023
1 parent 37421b3 commit ca8f129
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"rdef",
"refcell",
"RUSTDOCFLAGS",
"rustfmt",
"rustls",
"rustversion",
"serde",
Expand Down
27 changes: 27 additions & 0 deletions actix-client-ip-cloudflare/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,33 @@
//! trusted IP set using [`fetch_trusted_cf_ips()`] and add any further trusted ranges to that.
//! 1. Use the [`TrustedClientIp`] extractor in your handlers.
//!
//! # Example
//!
//! ```no_run
//! # async {
//! # use actix_web::{App, get, HttpServer};
//! use actix_client_ip_cloudflare::{fetch_trusted_cf_ips, TrustedClientIp};
//!
//! let cloudflare_ips = fetch_trusted_cf_ips()
//! # // rustfmt ignore
//! .await
//! .unwrap()
//! .add_loopback_ips();
//!
//! HttpServer::new(move || {
//! App::new()
//! # // rustfmt ignore
//! .app_data(cloudflare_ips.clone())
//! .service(handler)
//! });
//!
//! #[get("/")]
//! async fn handler(client_ip: TrustedClientIp) -> String {
//! client_ip.to_string()
//! }
//! # };
//! ```
//!
//! # Crate Features
//!
//! `fetch-ips` (default): Enables functionality to (asynchronously) fetch Cloudflare's trusted IP list from
Expand Down

0 comments on commit ca8f129

Please sign in to comment.