File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
lambda-runtime-api-client/src Expand file tree Collapse file tree 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};
1414use tower_service:: Service ;
1515
1616const 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" ) ;
1819
1920/// Error type that lambdas may result in
2021pub type Error = Box < dyn std:: error:: Error + Send + Sync + ' static > ;
@@ -128,7 +129,13 @@ where
128129/// Create a request builder.
129130/// This builder uses `aws-lambda-rust/CRATE_VERSION` as
130131/// the default User-Agent.
132+ /// Configure environment variable `LAMBDA_RUNTIME_USER_AGENT`
133+ /// at compile time to modify User-Agent value.
131134pub 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+ } ;
132139 http:: Request :: builder ( ) . header ( USER_AGENT_HEADER , USER_AGENT )
133140}
134141
You can’t perform that action at this time.
0 commit comments