Skip to content

In Annotations Framework how can I get all parameters passed with a wildcard? #1683

Answered by normj
lorenh asked this question in Q&A
Discussion options

You must be logged in to vote

As @ashishdhingra mention you can inject the raw request into the function's parameters to get access to the raw query string.

[LambdaFunction(Policies = "AWSLambdaBasicExecutionRole", MemorySize = 512, Timeout = 30)]
[RestApi(LambdaHttpMethod.Get, "/{product}")]
public IHttpResult Get(string product, APIGatewayProxyRequest rawRequest, ILambdaContext context)
{
    var builder = new StringBuilder();
    builder.AppendLine("Product: " + product);
    if (rawRequest.QueryStringParameters != null)
    {
        builder.AppendLine("Query String:");
        foreach (var query in rawRequest.QueryStringParameters)
        {
            builder.AppendLine($"\t{query.Key}: {query.Value}");
        }

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by lorenh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
response-requested Waiting on additional info and feedback. Will move to close soon in 7 days. annotations
3 participants