fix: axum inbox
Co-Authored-By: j0 <me@j0.lol>
This commit is contained in:
parent
8f0fdfaea9
commit
4d7ebc3493
1 changed files with 11 additions and 9 deletions
|
|
@ -11,9 +11,9 @@ use crate::{
|
||||||
};
|
};
|
||||||
use axum::{
|
use axum::{
|
||||||
async_trait,
|
async_trait,
|
||||||
body::{Bytes, HttpBody},
|
body::{Body, HttpBody},
|
||||||
extract::FromRequest,
|
extract::FromRequest,
|
||||||
http::{Request, StatusCode},
|
http::StatusCode,
|
||||||
response::{IntoResponse, Response},
|
response::{IntoResponse, Response},
|
||||||
};
|
};
|
||||||
use http::{HeaderMap, Method, Uri};
|
use http::{HeaderMap, Method, Uri};
|
||||||
|
|
@ -59,21 +59,23 @@ pub struct ActivityData {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<S, B> FromRequest<S, B> for ActivityData
|
impl<S> FromRequest<S> for ActivityData
|
||||||
where
|
where
|
||||||
Bytes: FromRequest<S, B>,
|
Body: HttpBody + Send + 'static,
|
||||||
B: HttpBody + Send + 'static,
|
|
||||||
S: Send + Sync,
|
S: Send + Sync,
|
||||||
<B as HttpBody>::Error: std::fmt::Display,
|
<axum::body::Body as HttpBody>::Error: std::fmt::Display,
|
||||||
<B as HttpBody>::Data: Send,
|
<axum::body::Body as HttpBody>::Data: Send,
|
||||||
{
|
{
|
||||||
type Rejection = Response;
|
type Rejection = Response;
|
||||||
|
|
||||||
async fn from_request(req: Request<B>, _state: &S) -> Result<Self, Self::Rejection> {
|
async fn from_request(
|
||||||
|
req: axum::extract::Request,
|
||||||
|
_state: &S,
|
||||||
|
) -> Result<Self, Self::Rejection> {
|
||||||
let (parts, body) = req.into_parts();
|
let (parts, body) = req.into_parts();
|
||||||
|
|
||||||
// this wont work if the body is an long running stream
|
// 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
|
.await
|
||||||
.map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response())?;
|
.map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response())?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue