|
@@ -2,6 +2,7 @@ namespace App
|
|
|
|
|
|
open System
|
|
open System
|
|
open Oxpecker
|
|
open Oxpecker
|
|
|
|
+open System.Runtime.InteropServices
|
|
|
|
|
|
[<RequireQualifiedAccess>]
|
|
[<RequireQualifiedAccess>]
|
|
module HtmlViews =
|
|
module HtmlViews =
|
|
@@ -26,21 +27,20 @@ module HtmlViews =
|
|
) |> RenderHelpers.prerender
|
|
) |> RenderHelpers.prerender
|
|
|
|
|
|
let fortunes (fortunesData: ResizeArray<Fortune>) =
|
|
let fortunes (fortunesData: ResizeArray<Fortune>) =
|
|
- RenderHelpers.combine head tail (
|
|
|
|
- __() {
|
|
|
|
- for fortune in fortunesData do
|
|
|
|
- tr() {
|
|
|
|
- td() { raw <| string fortune.id }
|
|
|
|
- td() { fortune.message }
|
|
|
|
- }
|
|
|
|
|
|
+ let fragment = __()
|
|
|
|
+ for fortune in CollectionsMarshal.AsSpan fortunesData do
|
|
|
|
+ tr() {
|
|
|
|
+ td() { raw <| string fortune.id }
|
|
|
|
+ td() { fortune.message }
|
|
}
|
|
}
|
|
- )
|
|
|
|
|
|
+ |> fragment.AddChild
|
|
|
|
+ RenderHelpers.combine head tail fragment
|
|
|
|
|
|
[<RequireQualifiedAccess>]
|
|
[<RequireQualifiedAccess>]
|
|
module HttpHandlers =
|
|
module HttpHandlers =
|
|
open System.Text
|
|
open System.Text
|
|
open Microsoft.AspNetCore.Http
|
|
open Microsoft.AspNetCore.Http
|
|
- open System.Text.Json
|
|
|
|
|
|
+ open SpanJson
|
|
|
|
|
|
let private extra =
|
|
let private extra =
|
|
{
|
|
{
|
|
@@ -98,9 +98,9 @@ module HttpHandlers =
|
|
ctx.WriteBytes(result)
|
|
ctx.WriteBytes(result)
|
|
|
|
|
|
let jsonSimple value : EndpointHandler =
|
|
let jsonSimple value : EndpointHandler =
|
|
- let options = JsonSerializerOptions(JsonSerializerDefaults.Web)
|
|
|
|
fun ctx ->
|
|
fun ctx ->
|
|
- ctx.Response.WriteAsJsonAsync(value, options)
|
|
|
|
|
|
+ ctx.SetContentType("application/json")
|
|
|
|
+ JsonSerializer.Generic.Utf8.SerializeAsync<_>(value, stream = ctx.Response.Body).AsTask()
|
|
|
|
|
|
let endpoints =
|
|
let endpoints =
|
|
[|
|
|
[|
|