I presented at the 2016 Desert Code Camp. The topic was WebAPI with F#. I also did a video series to go along with the talk. The talk and video series basically goes over how to use F# in a functional manner by building out all the pieces from scratch.
Here’s the series, hope you enjoy it!
F# WebAPI From Start to Finish.
Some set up steps and notes that are important to the success of the project:
Rather than using a custom Railway-Oriented code like in the videos you can use Chessie.
I’ve updated my validation library.
Setting Up Your Project
- Install Visual F# Power Tools
- Create new C# WebAPI
- Create new F# Library
- Add reference to F# Library from C# project.
- Make sure works
- Add reference to System.Net.Http
- Add reference to System.Web.Http → Need to install Nuget package Microsoft.AspNet.WebApi.Core
- Add configuration
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
- Add FSharp Converters
- JsonProvider → Use FSharp.Data from Nuget
- Connecting to a database using FSharp.Data.SqlClient