From 73e852c7a933d1797a36f6d3a2fcd3a4267322a1 Mon Sep 17 00:00:00 2001 From: Ibraheem Ahmed Date: Tue, 22 Jun 2021 11:15:37 -0400 Subject: [PATCH] add `Uri` example --- src/extract.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/extract.rs b/src/extract.rs index c5d1eb58f..09615f572 100644 --- a/src/extract.rs +++ b/src/extract.rs @@ -218,6 +218,22 @@ where } } +/// Extract the request's uri. +/// +/// ## Example +/// +/// ``` +/// use actix_web::{web, App, HttpRequest, http::Uri}; +/// +/// async fn index(uri: Uri) -> &'static str { +/// log::info!("Incoming request to: {}", uri.path()); +/// "Welcome!" +/// } +/// +/// fn main() { +/// let app = App::new().route("/", web::get().to(index)); +/// } +/// ``` impl FromRequest for Uri { type Error = Infallible; type Future = Ready>;