Skip to content

Instantly share code, notes, and snippets.

@DominicFinn
Created July 4, 2014 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DominicFinn/3526e3f74316239305a8 to your computer and use it in GitHub Desktop.
Save DominicFinn/3526e3f74316239305a8 to your computer and use it in GitHub Desktop.
Nancy F# Example with parameter
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
@DominicFinn
Copy link
Author

Currently just messing about from the basic hello world example and working out how you can take parameters.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment