Skip to content

Commit

Permalink
Merge pull request #92 from dahlbyk/patch-1
Browse files Browse the repository at this point in the history
Add example to route all unhandled requests
  • Loading branch information
twitchax authored Jun 17, 2023
2 parents cd9f005 + d8372aa commit 6ad151f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ services
});
```

#### Route All Unhandled Requests

You can also route all unhandled requests to another server, e.g.

```csharp
app.UseStatusCodePages(async statusCodeContext =>
{
var context = statusCodeContext.HttpContext;
if (context.Response.StatusCode == StatusCodes.Status404NotFound)
{
var request = context.Features.Get<IHttpRequestFeature>();
if (request != null)
{
await context.HttpProxyAsync($"https://example.com{request.RawTarget}");
}
}
});
```

#### Existing Controller

You can define a proxy over a specific endpoint on an existing `Controller` by leveraging the `ProxyAsync` extension methods.
Expand Down

0 comments on commit 6ad151f

Please sign in to comment.