Skip to content

Instantly share code, notes, and snippets.

View GREsau's full-sized avatar
🍕

Graham Esau GREsau

🍕
View GitHub Profile
// Usage: in Startup.ConfigureServices, add:
// services.AddSingleton<IConfigureOptions<MvcOptions>, JsonPropertyMetadataProviderSetup>();
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
using Microsoft.Extensions.Options;

Summary

  • The requestContext.path property always contains the original "real" path, including any configured base path and/or API stage. In other words, if the request had come from a web browser, then the requestContext.path would be the full URL path in the user's address bar.
  • The top-level path property is identical to requestContext.path when the request is made to a custom domain, but when the request is made to the execute-api URL, path differs in that it does not contain the API stage.

Default (execute-api) API Gateway URL, stage specified in path

https://abcdef1234.execute-api.eu-west-1.amazonaws.com/default/foo/bar/

{
  "resource": "/{proxy+}",
 "path": "/foo/bar/",