1+ use crate :: webserver:: server_timing:: ServerTiming ;
12use crate :: AppState ;
23use actix_multipart:: form:: bytes:: Bytes ;
34use actix_multipart:: form:: tempfile:: TempFile ;
@@ -42,7 +43,7 @@ pub struct RequestInfo {
4243 pub clone_depth : u8 ,
4344 pub raw_body : Option < Vec < u8 > > ,
4445 pub oidc_claims : Option < OidcClaims > ,
45- pub server_timing : std :: cell :: RefCell < super :: server_timing:: ServerTiming > ,
46+ pub server_timing : Arc < super :: server_timing:: ServerTiming > ,
4647}
4748
4849impl RequestInfo {
@@ -63,7 +64,7 @@ impl RequestInfo {
6364 clone_depth : self . clone_depth + 1 ,
6465 raw_body : self . raw_body . clone ( ) ,
6566 oidc_claims : self . oidc_claims . clone ( ) ,
66- server_timing : std :: cell :: RefCell :: new ( self . server_timing . borrow ( ) . clone ( ) ) ,
67+ server_timing : Arc :: clone ( & self . server_timing ) ,
6768 }
6869 }
6970}
@@ -80,7 +81,7 @@ impl Clone for RequestInfo {
8081pub ( crate ) async fn extract_request_info (
8182 req : & mut ServiceRequest ,
8283 app_state : Arc < AppState > ,
83- server_timing : super :: server_timing :: ServerTiming ,
84+ server_timing : ServerTiming ,
8485) -> anyhow:: Result < RequestInfo > {
8586 let ( http_req, payload) = req. parts_mut ( ) ;
8687 let method = http_req. method ( ) . clone ( ) ;
@@ -126,7 +127,7 @@ pub(crate) async fn extract_request_info(
126127 clone_depth : 0 ,
127128 raw_body,
128129 oidc_claims,
129- server_timing : std :: cell :: RefCell :: new ( server_timing) ,
130+ server_timing : Arc :: new ( server_timing) ,
130131 } )
131132}
132133
@@ -279,7 +280,7 @@ async fn is_file_field_empty(
279280mod test {
280281 use super :: super :: http:: SingleOrVec ;
281282 use super :: * ;
282- use crate :: app_config:: AppConfig ;
283+ use crate :: { app_config:: AppConfig , webserver :: server_timing :: ServerTiming } ;
283284 use actix_web:: { http:: header:: ContentType , test:: TestRequest } ;
284285
285286 #[ actix_web:: test]
@@ -288,7 +289,7 @@ mod test {
288289 serde_json:: from_str :: < AppConfig > ( r#"{"listen_on": "localhost:1234"}"# ) . unwrap ( ) ;
289290 let mut service_request = TestRequest :: default ( ) . to_srv_request ( ) ;
290291 let app_data = Arc :: new ( AppState :: init ( & config) . await . unwrap ( ) ) ;
291- let server_timing = super :: server_timing :: ServerTiming :: new ( false ) ;
292+ let server_timing = ServerTiming :: default ( ) ;
292293 let request_info = extract_request_info ( & mut service_request, app_data, server_timing)
293294 . await
294295 . unwrap ( ) ;
@@ -307,7 +308,7 @@ mod test {
307308 . set_payload ( "my_array[]=3&my_array[]=Hello%20World&repeated=1&repeated=2" )
308309 . to_srv_request ( ) ;
309310 let app_data = Arc :: new ( AppState :: init ( & config) . await . unwrap ( ) ) ;
310- let server_timing = super :: server_timing :: ServerTiming :: new ( false ) ;
311+ let server_timing = ServerTiming :: default ( ) ;
311312 let request_info = extract_request_info ( & mut service_request, app_data, server_timing)
312313 . await
313314 . unwrap ( ) ;
@@ -357,7 +358,7 @@ mod test {
357358 )
358359 . to_srv_request ( ) ;
359360 let app_data = Arc :: new ( AppState :: init ( & config) . await . unwrap ( ) ) ;
360- let server_timing = super :: server_timing :: ServerTiming :: new ( false ) ;
361+ let server_timing = ServerTiming :: enabled ( false ) ;
361362 let request_info = extract_request_info ( & mut service_request, app_data, server_timing)
362363 . await
363364 . unwrap ( ) ;
0 commit comments