You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/minimal-apis/handle-errors/includes/handle-errors7.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ In a Minimal API app, there are two different built-in centralized mechanisms to
11
11
12
12
This section refers to the following Minimal API app to demonstrate ways to handle exceptions. It throws an exception when the endpoint `/exception` is requested:
13
13
14
-
```csharp
14
+
```csharp
15
15
varbuilder=WebApplication.CreateBuilder(args);
16
16
varapp=builder.Build();
17
17
@@ -65,7 +65,7 @@ In non-development environments, use the [Exception Handler Middleware](xref:fun
65
65
For example, the following code changes the app to respond with an [RFC 7807](https://tools.ietf.org/html/rfc7807)-compliant payload to the client. For more information, see [Problem Details](#problem-details) section.
66
66
67
67
68
-
```csharp
68
+
```csharp
69
69
varbuilder=WebApplication.CreateBuilder(args);
70
70
varapp=builder.Build();
71
71
@@ -84,7 +84,7 @@ app.Run();
84
84
85
85
Consider the following Minimal API app.
86
86
87
-
```csharp
87
+
```csharp
88
88
varbuilder=WebApplication.CreateBuilder(args);
89
89
varapp=builder.Build();
90
90
@@ -103,7 +103,7 @@ The [`Status Code Pages middleware`](xref:fundamentals/error-handling#sestatusco
103
103
104
104
For example, the following example changes the app to respond with an [RFC 7807](https://tools.ietf.org/html/rfc7807)-compliant payload to the client for all client and server responses, including routing errors (for example, `404 NOT FOUND`). For more information, see the [Problem Details](#problem-details) section.
105
105
106
-
```csharp
106
+
```csharp
107
107
varbuilder=WebApplication.CreateBuilder(args);
108
108
varapp=builder.Build();
109
109
@@ -127,7 +127,7 @@ Minimal API apps can be configured to generate problem details response for all
127
127
128
128
The following code configures the app to generate problem details:
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/servers/httpsys.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ The preceding Windows 11 Build versions may require the use of a [Windows Inside
76
76
77
77
HTTP/3 is discovered as an upgrade from HTTP/1.1 or HTTP/2 via the `alt-svc` header. That means the first request will normally use HTTP/1.1 or HTTP/2 before switching to HTTP/3. Http.Sys doesn't automatically add the `alt-svc` header, it must be added by the application. The following code is a middleware example that adds the `alt-svc` response header.
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/servers/httpsys/includes/httpsys5-7.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ The preceding Windows 11 Build versions may require the use of a [Windows Inside
60
60
61
61
HTTP/3 is discovered as an upgrade from HTTP/1.1 or HTTP/2 via the `alt-svc` header. That means the first request will normally use HTTP/1.1 or HTTP/2 before switching to HTTP/3. Http.Sys doesn't automatically add the `alt-svc` header, it must be added by the application. The following code is a middleware example that adds the `alt-svc` response header.
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/servers/yarp/authn-authz.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ No authentication or authorization is performed on requests unless enabled in th
23
23
Authorization policies can be specified per route via [RouteConfig.AuthorizationPolicy](xref:Yarp.ReverseProxy.Configuration.RouteConfig) and can be bound from the `Routes` sections of the config file. As with other route properties, this can be modified and reloaded without restarting the proxy. Policy names are case insensitive.
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/servers/yarp/config-files.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ The reverse proxy can load configuration for routes and clusters from files usin
17
17
18
18
## Loading Configuration
19
19
To load the proxy configuration from IConfiguration add the following code in Program.cs:
20
-
```c#
20
+
```csharp
21
21
usingMicrosoft.AspNetCore.Builder;
22
22
usingMicrosoft.Extensions.DependencyInjection;
23
23
@@ -42,13 +42,13 @@ Configuration can be modified during the load sequence using [Configuration Filt
42
42
## Multiple Configuration Sources
43
43
As of 1.1, YARP supports loading the proxy configuration from multiple sources. LoadFromConfig may be called multiple times referencing different IConfiguration sections or may be combine with a different config source like InMemory. Routes can reference clusters from other sources. Note merging partial config from different sources for a given route or cluster is not supported.
@@ -62,7 +62,7 @@ File-based configuration is dynamically mapped to the types in [Yarp.ReverseProx
62
62
The configuration consists of a named section that you specified above via `Configuration.GetSection("ReverseProxy")`, and contains subsections for routes and clusters.
63
63
64
64
Example:
65
-
```JSON
65
+
```json
66
66
{
67
67
"ReverseProxy": {
68
68
"Routes": {
@@ -105,7 +105,7 @@ The clusters section is an unordered collection of named clusters. A cluster pri
105
105
For additional fields see [ClusterConfig](xref:Yarp.ReverseProxy.Configuration.ClusterConfig).
106
106
107
107
## All config properties
108
-
```JSON
108
+
```json
109
109
{
110
110
// Base URLs the server listens on, must be configured independently of the routes below
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/servers/yarp/config-filters.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ Filters can be used for a variety of purposes such as:
25
25
## AddConfigFilter
26
26
Configuration filters are registered in the Dependency Injection system using the [AddConfigFilter](xref:Microsoft.Extensions.DependencyInjection.ReverseProxyServiceCollectionExtensions) API. Any number of unique filters can be added and will be applied in the order added.
27
27
28
-
```C#
28
+
```csharp
29
29
// Load the configuration and register a config filter
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/servers/yarp/cors.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ The requests won't be automatically matched for cors preflight requests unless e
23
23
CORS policies can be specified per route via [RouteConfig.CorsPolicy](xref:Yarp.ReverseProxy.Configuration.RouteConfig) and can be bound from the `Routes` sections of the config file. As with other route properties, this can be modified and reloaded without restarting the proxy. Policy names are case insensitive.
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/servers/yarp/dests-health-checks.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ YARP can proactively monitor destination health by sending periodic probing requ
19
19
There are several cluster-wide configuration settings controlling active health checks that can be set either in the config file or in code. A dedicated health endpoint can also be specified per destination.
20
20
21
21
#### File example
22
-
```JSON
22
+
```json
23
23
"Clusters": {
24
24
"cluster1": {
25
25
"HealthCheck": {
@@ -49,7 +49,7 @@ There are several cluster-wide configuration settings controlling active health
49
49
```
50
50
51
51
#### Code example
52
-
```C#
52
+
```csharp
53
53
varclusters=new[]
54
54
{
55
55
newClusterConfig()
@@ -132,7 +132,7 @@ There are 2 main extensibility points in the active health check subsystem.
132
132
133
133
The below is a simple example of a custom `IActiveHealthCheckPolicy` marking destination as `Healthy`, if a successful response code was returned for a probe, and as `Unhealthy` otherwise.
@@ -169,13 +169,13 @@ public class FirstUnsuccessfulResponseHealthPolicy : IActiveHealthCheckPolicy
169
169
170
170
The default `IProbingRequestFactory` uses the same `HttpRequest` configuration as proxy requests, to customize that implement your own `IProbingRequestFactory` and register it in DI like the below.
The below is a simple example of a customer `IProbingRequestFactory` concatenating `DestinationConfig.Address` and a fixed health probe path to create the probing request URI.
@@ -196,7 +196,7 @@ There is one important difference from the active health check logic. Once a des
196
196
There are several cluster-wide configuration settings controlling passive health checks that can be set either in the config file or in code.
197
197
198
198
#### File example
199
-
```JSON
199
+
```json
200
200
"Clusters": {
201
201
"cluster1": {
202
202
"HealthCheck": {
@@ -222,7 +222,7 @@ There are several cluster-wide configuration settings controlling passive health
222
222
```
223
223
224
224
#### Code example
225
-
```C#
225
+
```csharp
226
226
varclusters=new[]
227
227
{
228
228
newClusterConfig()
@@ -252,7 +252,7 @@ Passive health check settings are specified on the cluster level in `Cluster/Hea
252
252
253
253
Passive health checks require the `PassiveHealthCheckMiddleware` added into the pipeline for them to work. The default `MapReverseProxy(this IEndpointRouteBuilder endpoints)` method does it automatically, but in case of a manual pipeline construction the [UsePassiveHealthChecks](xref:Microsoft.AspNetCore.Builder.AppBuilderHealthExtensions) method must be called to add that middleware as shown in the example below.
254
254
255
-
```C#
255
+
```csharp
256
256
endpoints.MapReverseProxy(proxyPipeline=>
257
257
{
258
258
proxyPipeline.UseAffinitizedDestinationLookup();
@@ -279,7 +279,7 @@ Global parameters are set via the options mechanism using `TransportFailureRateH
279
279
-`DefaultFailureRateLimit` - default failure rate limit for a destination to be marked as unhealthy that is applied if it's not set on a cluster's metadata. The value is in range `(0,1)`. Default is `0.3` (30%).
280
280
281
281
Global policy options can be set in code as follows:
@@ -318,7 +318,7 @@ There is one main extensibility point in the passive health check subsystem, the
318
318
319
319
The below is a simple example of a custom `IPassiveHealthCheckPolicy` marking destination as `Unhealthy` on the first unsuccessful response to a proxied request.
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/servers/yarp/diagnosing-yarp-issues.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,7 +114,7 @@ The [Metrics sample](https://github.com/microsoft/reverse-proxy/tree/main/sample
114
114
115
115
To use either of these, create a class implementing a [`Yarp.Telemetry.Consumption` interface](xref:Yarp.Telemetry.Consumption#interfaces), such as <xref:Yarp.Telemetry.Consumption.IForwarderTelemetryConsumer>:
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/servers/yarp/direct-forwarding.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ In this example the IHttpForwarder is registered in DI, injected into the endpoi
45
45
46
46
The optional transforms show how to copy all request headers except for the `Host`, it's common that the destination requires its own `Host` from the url.
47
47
48
-
```C#
48
+
```csharp
49
49
usingSystem;
50
50
usingSystem.Diagnostics;
51
51
usingSystem.Net;
@@ -136,7 +136,7 @@ internal class CustomTransformer : HttpTransformer
136
136
137
137
There are also [extension methods](xref:Microsoft.AspNetCore.Builder.DirectForwardingIEndpointRouteBuilderExtensions) available that simplify the mapping of IHttpForwarder to endpoints.
0 commit comments