store
store copied to clipboard
Submission : F# of-watchdog http template (ASP.NET Core v7)
Hello,
I would like to submit a proposal for an OpenFaaS template that uses F# and ASP.NET Core with .NET v6.0 (latest stable release). Here is a link to the repo containing the template: https://github.com/zakaluka/fsharp-httprequest-template
Why I made this template
While there are some .NET templates (csharp
, csharp-httprequest
, csharp-kestrel
), all of them are C# specific. While both F# and C# are .NET languages and (at least in my template) utilize ASP.NET Core under the hood, functional ASP.NET Core programming in F# is often accomplished using a wrapper like Giraffe (which is used here) or Saturn (not used in this template).
This new template uses Giraffe and the functional style advocated by Giraffe to build and expose a web service. Despite the addition of Giraffe, the template is relatively minimal and does not create a dependency on a database or other external platform.
Why to use this template?
- Based on https://github.com/distantcam/csharp-httprequest-template, an already-approved template for OpenFaaS .NET functions.
- Uses on .NET 6 (latest GA) and of-watchdog 0.9.6. This means that it uses Kestrel already because it is the default launch profile in .NET v6 and there is no need for separate templates like C# has.
- Uses F# programming paradigms for familiarity
- Provides working solution OOTB, user only has to tweak the routing and function to meet their needs.
- Easy to add dependencies, perform builds, testing, etc. using built-in .NET tools (
dotnet package add ...
)
Why not to use this template?
- Requires the latest .NET 6. Can be downgraded easily (in the easiest instance, by modifying the 2
.fspoj
files) to .NET v5, .NET Core v3, or .NET Framework v4.x, but this would be an end-user activity. - Does not provide a built-in framework like SAFE Stack - the template is purposely kept minimal in the spirit of FaaS solutions. However, all dependencies can be easily added by the user if they want to use SAFE or another framework.
- Does not use a non-ASP.NET Core web platform, like Suave or NancyFX.
Thank you for your time and consideration.
Update: Modified the routing function so that no change is required by the user - they can just modify the FunctionHandler body to take the desired action. The FunctionHanlder receives both path and query parameters (for GET), plus has access to other elements such as the payload of a POST (not implemented in sample).
This template has been updated to .NET 7 now