add `Uri` example

This commit is contained in:
Ibraheem Ahmed 2021-06-22 11:15:37 -04:00 committed by GitHub
parent d0771d4b68
commit 73e852c7a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -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<Result<Uri, Infallible>>;