-
I'm looking at [FromQuery] and see how it works with a well-known parameter, but in cases where there may be a variable number of unknown parameters passed to my HttpApi endpoint, is there a wildcard mechanism, or way to access the raw request information to get the unknown parameters that were passed? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@lorenh Based on my understanding, there isn't a way to specify wildcard mechanism in Annotations Framework. While on high level it might appear to have some kind of relation to ASP.NET framework, using annotations framework leverages source generators, which:
Hence, there is no concept of ASP.NET's CCing @normj for any other inputs. Thanks, |
Beta Was this translation helpful? Give feedback.
-
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}");
}
}
context.Logger.LogInformation(builder.ToString());
return HttpResults.Ok(builder.ToString())
.AddHeader("Content-Type", "text/plain");
} |
Beta Was this translation helpful? Give feedback.
As @ashishdhingra mention you can inject the raw request into the function's parameters to get access to the raw query string.