File tree 1 file changed +8
-1
lines changed
lambda-runtime-api-client/src
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ use tokio::io::{AsyncRead, AsyncWrite};
14
14
use tower_service:: Service ;
15
15
16
16
const USER_AGENT_HEADER : & str = "User-Agent" ;
17
- const USER_AGENT : & str = concat ! ( "aws-lambda-rust/" , env!( "CARGO_PKG_VERSION" ) ) ;
17
+ const DEFAULT_USER_AGENT : & str = concat ! ( "aws-lambda-rust/" , env!( "CARGO_PKG_VERSION" ) ) ;
18
+ const CUSTOM_USER_AGENT : Option < & str > = option_env ! ( "LAMBDA_RUNTIME_USER_AGENT" ) ;
18
19
19
20
/// Error type that lambdas may result in
20
21
pub type Error = Box < dyn std:: error:: Error + Send + Sync + ' static > ;
@@ -128,7 +129,13 @@ where
128
129
/// Create a request builder.
129
130
/// This builder uses `aws-lambda-rust/CRATE_VERSION` as
130
131
/// the default User-Agent.
132
+ /// Configure environment variable `LAMBDA_RUNTIME_USER_AGENT`
133
+ /// at compile time to modify User-Agent value.
131
134
pub fn build_request ( ) -> http:: request:: Builder {
135
+ const USER_AGENT : & str = match CUSTOM_USER_AGENT {
136
+ Some ( value) => value,
137
+ None => DEFAULT_USER_AGENT ,
138
+ } ;
132
139
http:: Request :: builder ( ) . header ( USER_AGENT_HEADER , USER_AGENT )
133
140
}
134
141
You can’t perform that action at this time.
0 commit comments