-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/LogOtter.Azure.AppServices.RequestMiddleware/ConfigureExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
|
||
namespace LogOtter.Azure.AppServices.RequestMiddleware; | ||
|
||
public static class ConfigureExtensions | ||
{ | ||
public static WebApplication UseRestoreRawRequestPathMiddleware(this WebApplication webApplication) | ||
{ | ||
webApplication.UseMiddleware<RestoreRawRequestPathMiddleware>(); | ||
webApplication.UseRouting(); | ||
|
||
return webApplication; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...r.Azure.AppServices.RequestMiddleware/LogOtter.Azure.AppServices.RequestMiddleware.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace>LogOtter.Azure.AppServices.RequestMiddleware</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
</ItemGroup> | ||
|
||
</Project> |
17 changes: 17 additions & 0 deletions
17
src/LogOtter.Azure.AppServices.RequestMiddleware/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
> ⚠️ Warning: LogOtter is still in beta and there are likely to be breaking changes prior to a v1 release. Use at your own peril! | ||
# Azure AppServices RequestMiddleware | ||
|
||
Adds middleware for converting the request back to the original request (Azure AppServices | ||
decode path strings and there is currently no way to disable). | ||
|
||
For more information see [dotnet/aspnetcore#40532](https://github.com/dotnet/aspnetcore/issues/40532) | ||
and [Azure/azure-functions-host#9402](https://github.com/Azure/azure-functions-host/pull/9402#issuecomment-1747347531) | ||
|
||
## Examples | ||
|
||
Register the middleware | ||
|
||
```c# | ||
app.UseRestoreRawRequestPathMiddleware(); | ||
``` |
25 changes: 25 additions & 0 deletions
25
src/LogOtter.Azure.AppServices.RequestMiddleware/RestoreRawRequestPathMiddleware.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace LogOtter.Azure.AppServices.RequestMiddleware; | ||
|
||
public class RestoreRawRequestPathMiddleware | ||
{ | ||
private const string UnencodedUrlHeaderName = "X-Waws-Unencoded-Url"; | ||
|
||
private readonly RequestDelegate _next; | ||
|
||
public RestoreRawRequestPathMiddleware(RequestDelegate next) | ||
{ | ||
_next = next; | ||
} | ||
|
||
public async Task Invoke(HttpContext context) | ||
{ | ||
if (context.Request.Headers.TryGetValue(UnencodedUrlHeaderName, out var unencodedUrlValue) && unencodedUrlValue.Any()) | ||
{ | ||
context.Request.Path = new PathString(unencodedUrlValue.First()); | ||
} | ||
|
||
await _next(context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters