Created
April 11, 2017 15:27
-
-
Save neoeinstein/2dbb98c59e57337dfb8765b733c8e962 to your computer and use it in GitHub Desktop.
Minimal example resulting in a 410 Gone response
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
module Api | |
open Freya.Machines.Http | |
let root = HttpMachine.Freya <| freyaMachine { | |
exists false | |
gone true | |
} |
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
/// Provides a nicer interop for configuring and starting the Kestrel server. | |
module KestrelInterop | |
open Freya.Core | |
open Microsoft.AspNetCore.Http | |
open Microsoft.AspNetCore.Builder | |
open Microsoft.AspNetCore.Hosting | |
module ApplicationBuilder = | |
let inline useFreya f (app:IApplicationBuilder)= | |
let owin : OwinMidFunc = OwinMidFunc.ofFreya f | |
app.UseOwin(fun p -> p.Invoke owin) | |
module WebHost = | |
let create () = WebHostBuilder().UseKestrel() | |
let bindTo urls (b:IWebHostBuilder) = b.UseUrls urls | |
let configure (f : IApplicationBuilder -> IApplicationBuilder) (b:IWebHostBuilder) = | |
b.Configure (System.Action<_> (f >> ignore)) | |
let build (b:IWebHostBuilder) = b.Build() | |
let run (wh:IWebHost) = wh.Run() | |
let buildAndRun : IWebHostBuilder -> unit = build >> run |
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
module Program | |
open KestrelInterop | |
[<EntryPoint>] | |
let main argv = | |
let configureApp = | |
ApplicationBuilder.useFreya Api.root | |
WebHost.create () | |
|> WebHost.bindTo [|"http://localhost:5000"|] | |
|> WebHost.configure configureApp | |
|> WebHost.buildAndRun | |
0 // return an integer exit code |
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
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>netcoreapp1.1</TargetFramework> | |
<ServerGarbageCollection>true</ServerGarbageCollection> | |
<ConcurrentGarbageCollection>false</ConcurrentGarbageCollection> | |
</PropertyGroup> | |
<ItemGroup> | |
<Compile Include="Api.fs" /> | |
<Compile Include="KestrelInterop.fs" /> | |
<Compile Include="Program.fs" /> | |
</ItemGroup> | |
<ItemGroup> | |
<PackageReference Include="FSharp.NET.Sdk" Version="1.*" PrivateAssets="All" /> | |
<PackageReference Include="FSharp.Core" Version="4.*" /> | |
<PackageReference Include="Freya" Version="4.0.0-alpha-*"/> | |
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.*" /> | |
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="1.*" /> | |
</ItemGroup> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment