Lanayx / Oxpecker

ASP.NET Core based F# framework
MIT License
236 stars 9 forks source link

html result following minimal api guide not working? #12

Open jkone27 opened 6 months ago

jkone27 commented 6 months ago

// minimal api doe not support this natively
type HtmlResult(html) =
    interface IResult with
        member this.ExecuteAsync(httpContext) =
            httpContext.Response.ContentType <- MediaTypeNames.Text.Html
            httpContext.Response.ContentLength <- Encoding.UTF8.GetByteCount(s = html)
            httpContext.Response.WriteAsync(html)

    static member Create(html) = new HtmlResult(html)

this could be an html return type, when returned in middleware seems not working?

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/responses?view=aspnetcore-8.0

Lanayx commented 6 months ago

Oxpecker is built on the EndpointHandler abstraction (similar to Giraffe). However you can use IResult as well, you can check the documentation.