@@ -28,7 +28,6 @@ use actix_web::{
2828use futures_util:: future:: LocalBoxFuture ;
2929
3030use crate :: {
31- audit:: AuditLogBuilder ,
3231 handlers:: {
3332 AUTHORIZATION_KEY , KINESIS_COMMON_ATTRIBUTES_KEY , LOG_SOURCE_KEY , LOG_SOURCE_KINESIS ,
3433 STREAM_NAME_HEADER_KEY ,
@@ -46,16 +45,16 @@ use serde::{Deserialize, Serialize};
4645
4746#[ derive( Serialize , Deserialize , Debug ) ]
4847#[ serde( rename_all = "camelCase" ) ]
49- struct Message {
50- common_attributes : CommonAttributes ,
48+ pub struct Message {
49+ pub common_attributes : CommonAttributes ,
5150}
5251
5352#[ derive( Serialize , Deserialize , Debug ) ]
54- struct CommonAttributes {
53+ pub struct CommonAttributes {
5554 #[ serde( rename = "Authorization" ) ]
5655 authorization : String ,
5756 #[ serde( rename = "X-P-Stream" ) ]
58- x_p_stream : String ,
57+ pub x_p_stream : String ,
5958}
6059
6160pub trait RouteExt {
@@ -138,7 +137,6 @@ where
138137 For requests made from other clients, no change.
139138
140139 ## Section start */
141- let mut stream_name = None ;
142140 if let Some ( kinesis_common_attributes) =
143141 req. request ( ) . headers ( ) . get ( KINESIS_COMMON_ATTRIBUTES_KEY )
144142 {
@@ -156,27 +154,14 @@ where
156154 HeaderName :: from_static ( LOG_SOURCE_KEY ) ,
157155 header:: HeaderValue :: from_static ( LOG_SOURCE_KINESIS ) ,
158156 ) ;
159- stream_name. replace ( message. common_attributes . x_p_stream ) ;
160- } else if let Some ( stream) = req. match_info ( ) . get ( "logstream" ) {
161- stream_name. replace ( stream. to_owned ( ) ) ;
162- } else if let Some ( value) = req. headers ( ) . get ( STREAM_NAME_HEADER_KEY ) {
163- if let Ok ( stream) = value. to_str ( ) {
164- stream_name. replace ( stream. to_owned ( ) ) ;
165- }
166157 }
167158
168159 /* ## Section end */
169160
170161 let auth_result: Result < _ , Error > = ( self . auth_method ) ( & mut req, self . action ) ;
171162
172- // Ensures that log will be pushed to subscriber on drop
173- let mut log_builder = AuditLogBuilder :: default ( ) ;
174- log_builder. set_stream_name ( stream_name. unwrap_or_default ( ) ) ;
175- log_builder. update_from_http ( & mut req) ;
176163 let fut = self . service . call ( req) ;
177164 Box :: pin ( async move {
178- log_builder. set_deployment_id ( ) . await ;
179-
180165 match auth_result? {
181166 rbac:: Response :: UnAuthorized => return Err (
182167 ErrorForbidden ( "You don't have permission to access this resource. Please contact your administrator for assistance." )
@@ -186,22 +171,8 @@ where
186171 ) ,
187172 _ => { }
188173 }
189- let res = fut. await ;
190-
191- // Capture status_code and error information from response
192- match & res {
193- Ok ( res) => {
194- let status = res. status ( ) ;
195- log_builder. response . status_code = status. as_u16 ( ) ;
196- // Use error information from reponse object if an error
197- if let Some ( err) = res. response ( ) . error ( ) {
198- log_builder. set_response_error ( err. to_string ( ) ) ;
199- }
200- }
201- Err ( err) => log_builder. set_response_error ( err. to_string ( ) ) ,
202- }
203174
204- res
175+ fut . await
205176 } )
206177 }
207178}
0 commit comments