HttpHandler.json.cs 792 B

123456789101112131415161718192021222324252627282930313233
  1. using BeetleX;
  2. using BeetleX.Light.Memory;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Text;
  7. using System.Text.Json;
  8. using System.Threading.Tasks;
  9. namespace PlatformBenchmarks
  10. {
  11. public partial class HttpHandler
  12. {
  13. public void Json(IStreamWriter stream)
  14. {
  15. stream.Write(_jsonPreamble.Data, 0, _jsonPreamble.Length);
  16. GMTDate.Default.Write(stream);
  17. var jsonWriter = GetJsonWriter(stream);
  18. using (var unflush = stream.UnFlush())
  19. {
  20. jsonWriter.WriteStartObject();
  21. jsonWriter.WriteString("message", "Hello, World!");
  22. jsonWriter.WriteEndObject();
  23. jsonWriter.Flush();
  24. }
  25. }
  26. }
  27. }