Skip to content

Commit e01966b

Browse files
committed
wip
1 parent 2ba690d commit e01966b

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

objectstore-server/src/endpoints/batch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use axum::routing;
55
use objectstore_service::id::ObjectContext;
66

77
use crate::auth::AuthAwareService;
8-
use crate::error::ApiResult;
8+
use crate::endpoints::common::ApiResult;
99
use crate::extractors::{BatchRequest, Xt};
1010
use crate::state::ServiceState;
1111

objectstore-server/src/extractors/batch.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::{fmt::Debug, pin::Pin};
1+
use std::fmt::Debug;
22

33
use anyhow::Context;
44
use axum::{
55
extract::{FromRequest, Request},
66
http::StatusCode,
7-
response::IntoResponse,
7+
response::{IntoResponse, Response},
88
};
99
use bytes::Bytes;
1010
use futures::{StreamExt, stream::BoxStream};
@@ -14,8 +14,6 @@ use multer::{Constraints, Multipart, SizeLimit};
1414
use objectstore_service::id::ObjectKey;
1515
use objectstore_types::Metadata;
1616

17-
use crate::error::AnyhowResponse;
18-
1917
#[derive(Debug)]
2018
pub struct GetOperation {
2119
pub key: ObjectKey,
@@ -95,37 +93,37 @@ impl<S> FromRequest<S> for BatchRequest
9593
where
9694
S: Send + Sync,
9795
{
98-
type Rejection = AnyhowResponse;
96+
type Rejection = Response;
9997

10098
async fn from_request(request: Request, _: &S) -> Result<Self, Self::Rejection> {
10199
let Some(content_type) = request
102100
.headers()
103101
.get(CONTENT_TYPE)
104102
.and_then(|ct| ct.to_str().ok())
105103
else {
106-
return Err((StatusCode::BAD_REQUEST, "expected valid Content-Type")
107-
.into_response()
108-
.into());
104+
return Err((StatusCode::BAD_REQUEST, "expected valid Content-Type").into_response());
109105
};
110106

111107
let Ok(mime) = content_type.parse::<mime::Mime>() else {
112-
return Err((StatusCode::BAD_REQUEST, "expected valid Content-Type")
113-
.into_response()
114-
.into());
108+
return Err((StatusCode::BAD_REQUEST, "expected valid Content-Type").into_response());
115109
};
116110
if !(mime.type_() == mime::MULTIPART && mime.subtype() == "mixed") {
117111
return Err((
118112
StatusCode::BAD_REQUEST,
119113
"expected Content-Type: multipart/mixed",
120114
)
121-
.into_response()
122-
.into());
115+
.into_response());
123116
}
124117

125118
// XXX: `multer::parse_boundary` requires the content-type to be `multipart/form-data`
126119
let content_type = content_type.replace("multipart/mixed", "multipart/form-data");
127-
let boundary =
128-
multer::parse_boundary(content_type).context("failed to parse multipart boundary")?;
120+
let Ok(boundary) = multer::parse_boundary(content_type) else {
121+
return Err((
122+
StatusCode::BAD_REQUEST,
123+
"failed to parse multipart boundary",
124+
)
125+
.into_response());
126+
};
129127
let mut parts = Multipart::with_constraints(
130128
request.into_body().into_data_stream(),
131129
boundary,

0 commit comments

Comments
 (0)