Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Http/Routing/test/testassets/RoutingWebSite/HelloExtension/HelloMiddleware.cs')
-rw-r--r--src/Http/Routing/test/testassets/RoutingWebSite/HelloExtension/HelloMiddleware.cs51
1 files changed, 25 insertions, 26 deletions
diff --git a/src/Http/Routing/test/testassets/RoutingWebSite/HelloExtension/HelloMiddleware.cs b/src/Http/Routing/test/testassets/RoutingWebSite/HelloExtension/HelloMiddleware.cs
index 2494ae7ea9..901f43ff3d 100644
--- a/src/Http/Routing/test/testassets/RoutingWebSite/HelloExtension/HelloMiddleware.cs
+++ b/src/Http/Routing/test/testassets/RoutingWebSite/HelloExtension/HelloMiddleware.cs
@@ -9,37 +9,36 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
-namespace RoutingWebSite.HelloExtension
+namespace RoutingWebSite.HelloExtension;
+
+public class HelloMiddleware
{
- public class HelloMiddleware
+ private readonly RequestDelegate _next;
+ private readonly HelloOptions _helloOptions;
+ private readonly byte[] _helloPayload;
+
+ public HelloMiddleware(RequestDelegate next, IOptions<HelloOptions> helloOptions)
{
- private readonly RequestDelegate _next;
- private readonly HelloOptions _helloOptions;
- private readonly byte[] _helloPayload;
+ _next = next;
+ _helloOptions = helloOptions.Value;
- public HelloMiddleware(RequestDelegate next, IOptions<HelloOptions> helloOptions)
+ var payload = new List<byte>();
+ payload.AddRange(Encoding.UTF8.GetBytes("Hello"));
+ if (!string.IsNullOrEmpty(_helloOptions.Greeter))
{
- _next = next;
- _helloOptions = helloOptions.Value;
-
- var payload = new List<byte>();
- payload.AddRange(Encoding.UTF8.GetBytes("Hello"));
- if (!string.IsNullOrEmpty(_helloOptions.Greeter))
- {
- payload.Add((byte)' ');
- payload.AddRange(Encoding.UTF8.GetBytes(_helloOptions.Greeter));
- }
- _helloPayload = payload.ToArray();
+ payload.Add((byte)' ');
+ payload.AddRange(Encoding.UTF8.GetBytes(_helloOptions.Greeter));
}
+ _helloPayload = payload.ToArray();
+ }
- public Task InvokeAsync(HttpContext context)
- {
- var response = context.Response;
- var payloadLength = _helloPayload.Length;
- response.StatusCode = 200;
- response.ContentType = "text/plain";
- response.ContentLength = payloadLength;
- return response.Body.WriteAsync(_helloPayload, 0, payloadLength);
- }
+ public Task InvokeAsync(HttpContext context)
+ {
+ var response = context.Response;
+ var payloadLength = _helloPayload.Length;
+ response.StatusCode = 200;
+ response.ContentType = "text/plain";
+ response.ContentLength = payloadLength;
+ return response.Body.WriteAsync(_helloPayload, 0, payloadLength);
}
}