Created
September 3, 2014 18:26
-
-
Save isaacabraham/42d0ecf539c4ed1fd7f3 to your computer and use it in GitHub Desktop.
Sample OWIN WebAPI startup in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.Web.Http | |
open Newtonsoft.Json.Serialization | |
open global.Owin | |
type Config = { | |
id : RouteParameter | |
} | |
type Startup() = | |
member __.Configuration(app:IAppBuilder) = | |
let config = | |
let config = new HttpConfiguration() | |
config.Formatters.Remove config.Formatters.XmlFormatter |> ignore // optional - don't emit data as XML | |
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver <- DefaultContractResolver() // optional - use the JSON serializer for F# types etc. | |
config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", { id = RouteParameter.Optional }) |> ignore // set up default web api route | |
config | |
app.UseWebApi config |> ignore // turn on Web API! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment