Просмотр исходного кода

Suave - F# web server (#3962)

* barebones suave app

* short suave description
Ademar Gonzalez 7 лет назад
Родитель
Сommit
256eb3def6

+ 23 - 0
frameworks/FSharp/suave/README.md

@@ -0,0 +1,23 @@
+# Suave Benchmarking Test
+
+Suave is a full async stand alone web server developed in F#
+
+### Test Type Implementation Source Code
+
+* [JSON](src/App/App.fs)
+* [PLAINTEXT](src/App/App.fs)
+
+## Important Libraries
+The tests were run with:
+* [Suave](https://suave.io/)
+
+## Test URLs
+### JSON
+
+http://localhost:8080/json
+
+### PLAINTEXT
+
+http://localhost:8080/plaintext
+
+

+ 26 - 0
frameworks/FSharp/suave/benchmark_config.json

@@ -0,0 +1,26 @@
+{
+  "framework": "suave",
+  "tests": [
+    {
+      "default": {
+        "json_url": "/json",
+        "plaintext_url": "/plaintext",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "database": "None",
+        "framework": "Suave",
+        "language": "FSharp",
+        "flavor": "None",
+        "orm": "None",
+        "platform": ".NET",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "Suave",
+        "notes": "",
+        "versus": "None"
+      }
+    }
+  ]
+}

+ 16 - 0
frameworks/FSharp/suave/src/App/App.fsproj

@@ -0,0 +1,16 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.0</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <Compile Include="Program.fs" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Suave" Version="2.5.0-beta2" />
+  </ItemGroup>
+
+</Project>

+ 20 - 0
frameworks/FSharp/suave/src/App/Program.fs

@@ -0,0 +1,20 @@
+open Suave
+open Suave.Filters
+open Suave.Operators
+open Suave.Json
+
+open System.Net
+open System.Runtime.Serialization
+
+[<DataContract>]
+type JsonMessage = {  [<field:DataMember(Name = "message")>] message: string }
+
+let app =
+  choose [
+    path "/plaintext" >=> Writers.setMimeType "text/plain; charset=utf-8" >=> Successful.OK "Hello, World!"
+    path "/json" >=> Writers.setMimeType "application/json; charset=utf-8" >=> Successful.ok (toJson { message = "Hello, World!"})
+  ]
+
+let cfg = { defaultConfig with bindings = [ HttpBinding.create HTTP IPAddress.Any 8080us ] }
+
+startWebServer cfg app

+ 7 - 0
frameworks/FSharp/suave/suave.dockerfile

@@ -0,0 +1,7 @@
+FROM microsoft/dotnet:2.1-sdk-stretch
+WORKDIR /app
+COPY src/App .
+RUN dotnet publish -c Release -o out
+RUN pwd
+RUN dir out/
+ENTRYPOINT ["dotnet", "out/App.dll"]