-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathProgram.fs
More file actions
28 lines (25 loc) · 822 Bytes
/
Program.fs
File metadata and controls
28 lines (25 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
open System
open ServiceStack
type Hello = { mutable Name: string; }
type HelloResponse = { mutable Result: string; }
type HelloService() =
interface IService
member this.Any (req:Hello) = { Result = "Hello, " + req.Name }
//Define the Web Services AppHost
type AppHost =
inherit AppSelfHostBase
new() = { inherit AppSelfHostBase("Hi F#!", typeof<HelloService>.Assembly) }
override this.Configure container =
base.Routes
.Add<Hello>("/hello")
.Add<Hello>("/hello/{Name}") |> ignore
//Run it!
[<EntryPoint>]
let main args =
let host = if args.Length = 0 then "http://*:1337/" else args.[0]
printfn "listening on %s ..." host
let appHost = new AppHost()
appHost.Init() |> ignore
appHost.Start host |> ignore
Console.ReadLine() |> ignore
0