PlainModule.cs 655 B

12345678910111213141516171819202122
  1. namespace Benchmarks
  2. {
  3. using Carter;
  4. using System.Text;
  5. public class PlainModule : CarterModule
  6. {
  7. private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
  8. public PlainModule() : base("plaintext")
  9. {
  10. Get("/", (req, res, routeData) =>
  11. {
  12. var payloadLength = _helloWorldPayload.Length;
  13. res.StatusCode = 200;
  14. res.ContentType = "text/plain";
  15. res.ContentLength = payloadLength;
  16. return res.Body.WriteAsync(_helloWorldPayload, 0, payloadLength);
  17. });
  18. }
  19. }
  20. }