Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
open System
open Microsoft.Owin.Hosting
let main argv =
let baseAddress = "http://localhost:8888"
use application = WebApp.Start<Startup.Startup>(baseAddress)
Console.WriteLine("Server running on {0}", baseAddress)
Console.WriteLine("hit <enter> to stop")
Console.ReadLine() |> ignore
0 // return an integer exit code
module Startup
open Owin
open Microsoft.Owin
open System
open System.IO
open System.Threading.Tasks
let transform (input: string) =
sprintf "%s transformed" input
type public Startup() =
let handleOwinContext (context:IOwinContext) =
use writer = new StreamWriter(context.Response.Body)
match context.Request.Method with
| "POST" ->
use reader = new StreamReader(context.Request.Body)
| _ ->
context.Response.StatusCode <- 400
writer.Write("Only POST")
let owinHandler = fun (context:IOwinContext) (_:Func<Task>) ->
handleOwinContext context;
Task.FromResult(null) :> Task
member x.Configuration (app:IAppBuilder) = app.Use(owinHandler) |> ignore
let private Main () =
printfn "%s" (transform "some input")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment