Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example to route all unhandled requests #92

Merged
merged 2 commits into from
Jun 17, 2023

Conversation

dahlbyk
Copy link
Contributor

@dahlbyk dahlbyk commented Mar 16, 2022

  1. Is this a useful example?
  2. Is there a better way to do this?

@twitchax
Copy link
Owner

@dahlbyk, ping here. :)

@dahlbyk
Copy link
Contributor Author

dahlbyk commented Nov 15, 2022

👋

var context = statusCodeContext.HttpContext;
if (context.Response.StatusCode == StatusCodes.Status404NotFound)
{
var request = context.Features.Get<IHttpRequestFeature>();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just use context.Request?

Copy link
Contributor Author

@dahlbyk dahlbyk Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible to stitch back together approximately what the request path+query was from HttpRequest, but passing through RawTarget unaltered seems more correct from a proxy standpoint (e.g. it works for an OPTIONS * request)

Gets or sets the request target as it was sent in the HTTP request.

@twitchax twitchax merged commit 6ad151f into twitchax:master Jun 17, 2023
@dahlbyk dahlbyk deleted the patch-1 branch June 17, 2023 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants