In AWS Lambda Adapter, we want to send a custom User_Agent to lambda Runtime API.
lambda-runtime-api-client has a default User_Agent string, e.g. "aws-lambda-rust/0.5.0". To allow custom User_Agent, we can set an environment variable CUSTOM_USER_AGENT at compiling time, like this.
const CUSTOM_USER_AGENT: Option<&str> = option_env!("CUSTOM_USER_AGENT");
And when building the http request, use its value if it is configured, otherwise send the default User_Agent. e.g.
pub fn build_request() -> http::request::Builder {
let user_agent = match CUSTOM_USER_AGENT {
Some(value) => value,
None => USER_AGENT,
};
http::Request::builder().header(USER_AGENT_HEADER, user_agent)
}
@calavera @nmoutschen What's your opinion?