瀏覽代碼

Revert to Utf8Json for serialization (#5211)

Stuart Lang 6 年之前
父節點
當前提交
851c9282c4
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      frameworks/FSharp/giraffe/src/App/Custom.fs

+ 3 - 2
frameworks/FSharp/giraffe/src/App/Custom.fs

@@ -44,12 +44,13 @@ let application : HttpHandler =
     let inline contentLength x = new Nullable<int64> ( int64 x )
 
     let json' data : HttpHandler =
+        let bytes = Utf8Json.JsonSerializer.Serialize(data)
         fun _ ctx -> 
-            ctx.Response.ContentLength <- contentLength BufferSize
+            ctx.Response.ContentLength <- contentLength bytes.Length
             ctx.Response.ContentType <- "application/json"
             ctx.Response.StatusCode <- 200
             task {
-                do! System.Text.Json.JsonSerializer.SerializeAsync(ctx.Response.Body, data)
+                do! ctx.Response.Body.WriteAsync(bytes, 0, bytes.Length)
                 return Some ctx
             }