-
Notifications
You must be signed in to change notification settings - Fork 267
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
how return css file via endpoint? #617
Comments
Hello, You might want to consider using the static files middleware, as outlined in the documentation at https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-8.0. It seems Giraffe doesn't offer any other built-in solutions for this. Have you explored potential solutions at https://giraffe.wiki/docs? The current content is lacking, and I believe we should add a new section there, even if it doesn't specifically pertain to Giraffe. |
That's a good idea, it could be added similarly how Response Caching was mentioned. It's mostly deferring that responsibility to the already available ASP.NET Core Middleware and I'd highly encourage to continue doing that wherever possible. The original ethos of Giraffe was always to make ASP.NET Core more functional and great experience for F# as well, not so much to complete with it doing things differently. Unless there is really good reason why Giraffe should have its own static file handler I think the ASP.NET Core middleware is the preferable option. Nothing prevents one though to expose a file themselves through a Giraffe handler. In HTTP there is no difference between a static file or a dynamic JSON response, both is just data returned in the HTTP body with slightly different headers. Someone can always stream the bytes from a file into the response and set the required HTTP headers (e.g. application/pdf or image/png, etc.) for the type of content that is being returned. It's just a plain handler like everything else. |
@darren-mk you can set a file server too. Check the .NET docs here. Check this PR for a sample using F#. |
Hi,
I see the following functions that emits
text/html
in Giraffe namespace but can't find one fortext/css
. How can I send css file through an endpoint?Thanks,
The text was updated successfully, but these errors were encountered: