Skip to content

Allow customized User_Agent used by lambda-runtime-api-client #452

@bnusunny

Description

@bnusunny

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions