forked from TechEmpower/FrameworkBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlainModule.cs
More file actions
26 lines (23 loc) · 774 Bytes
/
PlainModule.cs
File metadata and controls
26 lines (23 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System.Text;
using Carter;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
namespace Benchmarks
{
public class PlainModule : ICarterModule
{
private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
public void AddRoutes(IEndpointRouteBuilder app)
{
app.MapGet("/plaintext", (HttpResponse res) =>
{
var payloadLength = _helloWorldPayload.Length;
res.StatusCode = 200;
res.ContentType = "text/plain";
res.ContentLength = payloadLength;
return res.Body.WriteAsync(_helloWorldPayload, 0, payloadLength);
});
}
}
}