From b59c9c45fab8bbba1df4a5e6370aea1d8d07636e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=97=8D+85CD?= <50108258+kwaa@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:45:28 +0800 Subject: [PATCH] fix: docs test --- Cargo.toml | 2 +- docs/06_http_endpoints_axum.md | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 93f9436..488abe5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,7 +91,7 @@ moka = { version = "0.12.8", features = ["future"] } axum = { version = "0.7.5", features = [ "json", ], default-features = false, optional = true } -axum-extra = { version = "0.9.3", optional = true } +axum-extra = { version = "0.9.3", features = ["typed-header"], optional = true } tower = { version = "0.4.13", optional = true } hyper = { version = "1.4.1", optional = true } http-body-util = { version = "0.1.2", optional = true } diff --git a/docs/06_http_endpoints_axum.md b/docs/06_http_endpoints_axum.md index 3a33410..2feeb5a 100644 --- a/docs/06_http_endpoints_axum.md +++ b/docs/06_http_endpoints_axum.md @@ -15,9 +15,9 @@ The next step is to allow other servers to fetch our actors and objects. For thi # use activitypub_federation::config::FederationMiddleware; # use axum::routing::get; # use crate::activitypub_federation::traits::Object; -# use axum::headers::ContentType; +# use axum_extra::headers::ContentType; # use activitypub_federation::FEDERATION_CONTENT_TYPE; -# use axum::TypedHeader; +# use axum_extra::TypedHeader; # use axum::response::IntoResponse; # use http::HeaderMap; # async fn generate_user_html(_: String, _: Data) -> axum::response::Response { todo!() } @@ -33,11 +33,11 @@ async fn main() -> Result<(), Error> { .route("/user/:name", get(http_get_user)) .layer(FederationMiddleware::new(data)); - let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); - tracing::debug!("listening on {}", addr); - axum::Server::bind(&addr) - .serve(app.into_make_service()) - .await?; + let listener = tokio::net::TcpListener::bind("127.0.0.1:3000") + .await + .unwrap(); + tracing::debug!("listening on {}", listener.local_addr().unwrap()); + axum::serve(listener, app).await.unwrap(); Ok(()) }