Skip to content

Instantly share code, notes, and snippets.

@beyond-code-github
Last active August 29, 2015 14:11
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 beyond-code-github/c6aa203a2f11095494b8 to your computer and use it in GitHub Desktop.
Save beyond-code-github/c6aa203a2f11095494b8 to your computer and use it in GitHub Desktop.
Example of composition with Superscribe in F#
type NameBeginningWith(letter) as this =
inherit GraphNode()
do
this.ActivationFunction <- fun data segment -> segment.StartsWith(letter)
this.ActionFunctions.Add(
"set_param_Name",
fun data segment -> data.Parameters?Add("Name", segment));
type Startup() =
member x.Configuration(app: Owin.IAppBuilder) =
let define = OwinRouteEngineFactory.Create();
app.UseSuperscribeRouter(define).UseSuperscribeHandler(define) |> ignore
let hello = ConstantNode("hello")
define.Route(
hello / NameBeginningWith "p",
fun o ->
"Hello " + o?Parameters?Name + ", great first letter!" :> obj) |> ignore
define.Route(
hello / String "Name",
fun o ->
"Hello " + o?Parameters?Name :> obj) |> ignore
[<assembly: OwinStartup(typeof<Startup>)>]
do ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment