Skip to content

Add docs for short circuiting #28935

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

Closed
Tracked by #28596
adityamandaleeka opened this issue Apr 10, 2023 · 1 comment · Fixed by #29110
Closed
Tracked by #28596

Add docs for short circuiting #28935

adityamandaleeka opened this issue Apr 10, 2023 · 1 comment · Fixed by #29110
Assignees
Labels
8.0 .NET 8 doc-idea seQUESTered Identifies that an issue has been imported into Quest.

Comments

@adityamandaleeka
Copy link
Member

adityamandaleeka commented Apr 10, 2023

.NET 8 has a new feature for short circuiting routes. We should document it.

Some notes that may be useful...

When routing matches an endpoint it typically lets the rest of the middleware pipeline run before invoking the endpoint logic. If that's not necessary or desirable, there's a new option that will cause routing to invoke the endpoint logic immediately and then end the request. This can be used to efficiently respond to requests that don't require additional features like authentication, CORS, etc., such as requests for robots.txt or favicon.ico.

app.MapGet("/", () => "Hello World").ShortCircuit();

You can also use the MapShortCircuit method to setup endpoints that send a quick 404 or other status code for matched resources that you don't want to further process.

app.MapShortCircuit(404, "robots.txt", "favicon.ico");

More info:

EDIT by @Rick-Anderson to add the following metadata

Provide link in https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/ doc to ShortCircuit


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.


Associated WorkItem - 85531

@adityamandaleeka
Copy link
Member Author

cc: @Tratcher

@Rick-Anderson Rick-Anderson self-assigned this Apr 11, 2023
@Rick-Anderson Rick-Anderson added the reQUEST Triggers an issue to be imported into Quest label Apr 11, 2023
@Rick-Anderson Rick-Anderson reopened this Apr 17, 2023
@github-actions github-actions bot added seQUESTered Identifies that an issue has been imported into Quest. and removed reQUEST Triggers an issue to be imported into Quest labels Apr 18, 2023
@tdykstra tdykstra assigned tdykstra and unassigned Rick-Anderson Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.0 .NET 8 doc-idea seQUESTered Identifies that an issue has been imported into Quest.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants