-
Hi, I see the following functions that emits Thanks,
|
Beta Was this translation helpful? Give feedback.
Replies: 4 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. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
@darren-mk you can set a file server too. Check the .NET docs here. Check this PR for a sample using F#. |
Beta Was this translation helpful? Give feedback.
-
Moved this issue into a discussion. |
Beta Was this translation helpful? Give feedback.
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.