Last active
August 29, 2015 14:11
-
-
Save beyond-code-github/c6aa203a2f11095494b8 to your computer and use it in GitHub Desktop.
Example of composition with Superscribe in F#
This file contains hidden or 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
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