From 4d7ebc3493d06e6910c420b9c9478f96c6a72f28 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:29:26 +0800 Subject: [PATCH] fix: axum inbox Co-Authored-By: j0 --- src/axum/inbox.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/axum/inbox.rs b/src/axum/inbox.rs index 5bb147a..e8b89d7 100644 --- a/src/axum/inbox.rs +++ b/src/axum/inbox.rs @@ -11,9 +11,9 @@ use crate::{ }; use axum::{ async_trait, - body::{Bytes, HttpBody}, + body::{Body, HttpBody}, extract::FromRequest, - http::{Request, StatusCode}, + http::StatusCode, response::{IntoResponse, Response}, }; use http::{HeaderMap, Method, Uri}; @@ -59,21 +59,23 @@ pub struct ActivityData { } #[async_trait] -impl FromRequest for ActivityData +impl FromRequest for ActivityData where - Bytes: FromRequest, - B: HttpBody + Send + 'static, + Body: HttpBody + Send + 'static, S: Send + Sync, - ::Error: std::fmt::Display, - ::Data: Send, + ::Error: std::fmt::Display, + ::Data: Send, { type Rejection = Response; - async fn from_request(req: Request, _state: &S) -> Result { + async fn from_request( + req: axum::extract::Request, + _state: &S, + ) -> Result { let (parts, body) = req.into_parts(); // this wont work if the body is an long running stream - let bytes = hyper::body::to_bytes(body) + let bytes = axum::body::to_bytes(body, usize::MAX) .await .map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response())?;