-async fn hello(Path(name): Path<String>) -> impl response::IntoResponse {
- (StatusCode::OK, format!("Hello {}", name))
+async fn hello(Path(name): Path<String>, user_agent: Option<TypedHeader<axum::headers::UserAgent>>) -> impl response::IntoResponse {
+ if let Some(TypedHeader(user_agent)) = user_agent {
+ (StatusCode::OK, format!("Hello {} from {}", name, user_agent))
+ } else {
+ (StatusCode::OK, format!("Hello {}", name))
+ }