@@ -98,10 +98,10 @@ impl FlightService for FlightServiceImpl {
9898 }
9999
100100 async fn do_get ( & self , req : Request < Ticket > ) -> Result < Response < Self :: DoGetStream > , Status > {
101- let key = extract_session_key ( req. metadata ( ) ) ?;
101+ let key = extract_session_key ( req. metadata ( ) ) . map_err ( |e| * e ) ?;
102102 let ticket: serde_json:: Value = serde_json:: from_slice ( & req. into_inner ( ) . ticket )
103103 . map_err ( |err| Status :: internal ( err. to_string ( ) ) ) ?;
104- let stream = extract_stream ( & ticket) ?;
104+ let stream = extract_stream ( & ticket) . map_err ( |e| * e ) ?;
105105 info ! ( "livetail requested for stream {}" , stream) ;
106106 match Users . authorize ( key, rbac:: role:: Action :: Query , Some ( stream) , None ) {
107107 rbac:: Response :: Authorized => ( ) ,
@@ -232,16 +232,16 @@ pub fn server() -> impl Future<Output = Result<(), Box<dyn std::error::Error + S
232232 }
233233}
234234
235- pub fn extract_stream ( body : & serde_json:: Value ) -> Result < & str , Status > {
235+ pub fn extract_stream ( body : & serde_json:: Value ) -> Result < & str , Box < Status > > {
236236 body. as_object ( )
237- . ok_or ( Status :: invalid_argument ( "expected object in request body" ) ) ?
237+ . ok_or_else ( || Box :: new ( Status :: invalid_argument ( "expected object in request body" ) ) ) ?
238238 . get ( "stream" )
239- . ok_or ( Status :: invalid_argument ( "stream key value is not provided" ) ) ?
239+ . ok_or_else ( || Box :: new ( Status :: invalid_argument ( "stream key value is not provided" ) ) ) ?
240240 . as_str ( )
241- . ok_or ( Status :: invalid_argument ( "stream key value is invalid" ) )
241+ . ok_or_else ( || Box :: new ( Status :: invalid_argument ( "stream key value is invalid" ) ) )
242242}
243243
244- pub fn extract_session_key ( headers : & MetadataMap ) -> Result < SessionKey , Status > {
244+ pub fn extract_session_key ( headers : & MetadataMap ) -> Result < SessionKey , Box < Status > > {
245245 // Extract username and password from the request using basic auth extractor.
246246 let basic = extract_basic_auth ( headers) . map ( |creds| SessionKey :: BasicAuth {
247247 username : creds. user_id ,
@@ -261,7 +261,9 @@ pub fn extract_session_key(headers: &MetadataMap) -> Result<SessionKey, Status>
261261 return Ok ( SessionKey :: SessionId ( session) ) ;
262262 }
263263
264- Err ( Status :: unauthenticated ( "No authentication method supplied" ) )
264+ Err ( Box :: new ( Status :: unauthenticated (
265+ "No authentication method supplied" ,
266+ ) ) )
265267}
266268
267269fn extract_basic_auth ( header : & MetadataMap ) -> Option < Credentials > {
0 commit comments