@@ -25,6 +25,7 @@ use serde_json::json;
25
25
use tera:: { Context , Tera } ;
26
26
27
27
use self :: request:: { HeaderExt , RequestBuilderExt } ;
28
+ use super :: authentication:: { AuthInfo , AuthenticateAndFetch } ;
28
29
use crate :: {
29
30
configs:: settings:: { Connectors , Settings } ,
30
31
consts,
@@ -33,14 +34,13 @@ use crate::{
33
34
errors:: { self , CustomResult } ,
34
35
payments,
35
36
} ,
36
- events:: { api_logs:: ApiEvent , EventHandler } ,
37
+ events:: api_logs:: ApiEvent ,
37
38
logger,
38
39
routes:: {
39
40
app:: AppStateInfo ,
40
41
metrics:: { self , request as metrics_request} ,
41
42
AppState ,
42
43
} ,
43
- services:: authentication as auth,
44
44
types:: {
45
45
self ,
46
46
api:: { self , ConnectorCommon } ,
@@ -751,7 +751,7 @@ pub async fn server_wrap_util<'a, 'b, A, U, T, Q, F, Fut, E, OErr>(
751
751
request : & ' a HttpRequest ,
752
752
payload : T ,
753
753
func : F ,
754
- api_auth : & dyn auth :: AuthenticateAndFetch < U , A > ,
754
+ api_auth : & dyn AuthenticateAndFetch < U , A > ,
755
755
lock_action : api_locking:: LockAction ,
756
756
) -> CustomResult < ApplicationResponse < Q > , OErr >
757
757
where
@@ -761,7 +761,7 @@ where
761
761
Q : Serialize + Debug + ' a ,
762
762
T : Debug ,
763
763
A : AppStateInfo + Clone ,
764
- U : auth :: AuthInfo ,
764
+ U : AuthInfo ,
765
765
E : ErrorSwitch < OErr > + error_stack:: Context ,
766
766
OErr : ResponseError + error_stack:: Context ,
767
767
errors:: ApiErrorResponse : ErrorSwitch < OErr > ,
@@ -816,12 +816,15 @@ where
816
816
Ok ( res) => metrics:: request:: track_response_status_code ( res) ,
817
817
Err ( err) => err. current_context ( ) . status_code ( ) . as_u16 ( ) . into ( ) ,
818
818
} ;
819
- state. event_handler ( ) . log_event ( ApiEvent :: new (
820
- flow,
821
- & request_id,
822
- request_duration,
823
- status_code,
824
- ) ) ;
819
+ let api_event = ApiEvent :: new ( flow, & request_id, request_duration, status_code) ;
820
+ match api_event. clone ( ) . try_into ( ) {
821
+ Ok ( event) => {
822
+ state. event_handler ( ) . log_event ( event) ;
823
+ }
824
+ Err ( err) => {
825
+ logger:: error!( error=?err, event=?api_event, "Error Logging API Event" ) ;
826
+ }
827
+ }
825
828
826
829
metrics:: request:: status_code_metrics ( status_code, flow. to_string ( ) , merchant_id. to_string ( ) ) ;
827
830
@@ -838,15 +841,15 @@ pub async fn server_wrap<'a, A, T, U, Q, F, Fut, E>(
838
841
request : & ' a HttpRequest ,
839
842
payload : T ,
840
843
func : F ,
841
- api_auth : & dyn auth :: AuthenticateAndFetch < U , A > ,
844
+ api_auth : & dyn AuthenticateAndFetch < U , A > ,
842
845
lock_action : api_locking:: LockAction ,
843
846
) -> HttpResponse
844
847
where
845
848
F : Fn ( A , U , T ) -> Fut ,
846
849
Fut : Future < Output = CustomResult < ApplicationResponse < Q > , E > > ,
847
850
Q : Serialize + Debug + ' a ,
848
851
T : Debug ,
849
- U : auth :: AuthInfo ,
852
+ U : AuthInfo ,
850
853
A : AppStateInfo + Clone ,
851
854
ApplicationResponse < Q > : Debug ,
852
855
E : ErrorSwitch < api_models:: errors:: types:: ApiErrorResponse > + error_stack:: Context ,
0 commit comments