1- use std:: { fmt:: Debug , pin :: Pin } ;
1+ use std:: fmt:: Debug ;
22
33use anyhow:: Context ;
44use axum:: {
55 extract:: { FromRequest , Request } ,
66 http:: StatusCode ,
7- response:: IntoResponse ,
7+ response:: { IntoResponse , Response } ,
88} ;
99use bytes:: Bytes ;
1010use futures:: { StreamExt , stream:: BoxStream } ;
@@ -14,8 +14,6 @@ use multer::{Constraints, Multipart, SizeLimit};
1414use objectstore_service:: id:: ObjectKey ;
1515use objectstore_types:: Metadata ;
1616
17- use crate :: error:: AnyhowResponse ;
18-
1917#[ derive( Debug ) ]
2018pub struct GetOperation {
2119 pub key : ObjectKey ,
@@ -95,37 +93,37 @@ impl<S> FromRequest<S> for BatchRequest
9593where
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