Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.