Skip to content

Commit bf29678

Browse files
committed
Add short circuit example
1 parent 42e3e6b commit bf29678

File tree

6 files changed

+37
-5
lines changed

6 files changed

+37
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Samples for ASP.NET Core 6.0 (470)
1+
# Samples for ASP.NET Core 6.0 (471)
22

3-
Samples for ASP.NET Core **8.0 Preview 3** is available [here](/projects/.net8) (8).
3+
Samples for ASP.NET Core **8.0 Preview 3** is available [here](/projects/.net8) (9).
44

55
Samples for ASP.NET Core **7.0** is available [here](/projects/.net7) (45).
66

projects/.net8/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ASP.NET 8.0 Preview 3 (8)
1+
# ASP.NET 8.0 Preview 3 (9)
22

33
These samples require [.NET 8.0 Preview 3](https://dotnet.microsoft.com/en-us/download/dotnet/8.0).
44

@@ -33,4 +33,8 @@ These samples require [.NET 8.0 Preview 3](https://dotnet.microsoft.com/en-us/do
3333

3434
* [Request Timeout](request-timeout)
3535

36-
This sample demonstrates how to configure a request timeout.
36+
This sample demonstrates how to configure a request timeout.
37+
38+
* [Short Circuit](map-short-circuit)
39+
40+
Use `MapShortCircuit` or `.ShortCircuit()` to efficiently respond to a request without going through a middleware pipeline run.

projects/.net8/build.bat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ dotnet build RazorComponentOne
55
dotnet build RazorComponentSix
66
dotnet build RazorComponentThree
77
dotnet build RazorComponentTwo
8-
dotnet build request-timeout
8+
dotnet build request-timeout
9+
dotnet build map-short-circuit
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var builder = WebApplication.CreateBuilder();
2+
var app = builder.Build();
3+
4+
app.MapShortCircuit(404, "robots.txt", "favicon.ico");
5+
6+
app.MapGet("/", () => {
7+
return Results.Content("""
8+
<html>
9+
<body>
10+
hello world
11+
</body>
12+
</html>
13+
""", "text/html");
14+
}).ShortCircuit(200);
15+
16+
app.Run();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Use ShortCircuit
2+
3+
Use `MapShortCircuit` or `.ShortCircuit()` to efficiently respond to a request without going through a middleware pipeline run. It skips processes such as authentication, CORS, etc.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<ImplicitUsings>true</ImplicitUsings>
5+
<LangVersion>preview</LangVersion>
6+
<PreviewFeatures>true</PreviewFeatures>
7+
</PropertyGroup>
8+
</Project>

0 commit comments

Comments
 (0)