Created
July 4, 2014 14:03
-
-
Save DominicFinn/3526e3f74316239305a8 to your computer and use it in GitHub Desktop.
Nancy F# Example with parameter
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 | |
open Nancy | |
open Nancy.Hosting.Self | |
let (?) (parameters:obj) param = | |
(parameters :?> Nancy.DynamicDictionary).[param] | |
let sayHello(name) = | |
"hello " + name | |
type HelloModule() as this = | |
inherit NancyModule() | |
do | |
this.Get.["/{name}"] <- fun p -> sayHello(p?name.ToString()) :> obj | |
[<EntryPoint>] | |
let main args = | |
let nancyHost = new NancyHost(new Uri("http://localhost:8080/nancy/"), new Uri("http://127.0.0.1:8080/nancy/")) | |
nancyHost.Start() | |
printfn "running!" | |
printfn "Press any key to stop..." | |
Console.ReadKey() |> ignore | |
nancyHost.Stop() | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently just messing about from the basic hello world example and working out how you can take parameters.....