Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html result following minimal api guide not working? #12

Open
jkone27 opened this issue Mar 4, 2024 · 1 comment
Open

html result following minimal api guide not working? #12

jkone27 opened this issue Mar 4, 2024 · 1 comment
Labels
question Further information is requested

Comments

@jkone27
Copy link

jkone27 commented Mar 4, 2024

// 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
Copy link
Owner

Lanayx commented Mar 5, 2024

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

@Lanayx Lanayx added the question Further information is requested label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants