(new FinalFunction("GET", o => "Hello World")) Var helloRoute = new ConstantNode("Hello").Slash(new ConstantNode("World")) To respond to the uri in the link, we need to add some more nodes to our graph: In this case we have configured Superscribe to respond to a GET request to '/', returning a message and a link. Multiple final functions can be supplied, each responding to a different HTTP method. All other nodes in Superscribe derive from this class, and is the building block of all route definitions.įor example, if we want to respond to a request to '/', we need to provide the base node with a Final Function:Į(new FinalFunction("GET", o => to SuperscribeĪ Final Function is associated with an HTTP method and executed when routing finishes at a particular node. Base property of the Route Engine, and is an instance of type GraphNode. Within each instance of a RouteEngine there is a Base node that represents the root '/' url and is also the parent for any susequent route definitions. Graph Based Routing definitions are constructed using strongly typed nodes and then stored as a graph. Usually - as in most examples on this site - only one is needed (although it is possible to transfer control from one to another when moving between frameworks or application layers). You can have as many instances of IRouteEngine as you like, and they will operate indenpendently. Var engine = OwinRouteEngineFactory.Create() Var engine = RouteEngineFactory.Create() You can obtain an instance using the static factory classes provided, as follows: There are currently two Route Engine implementations, one for WebApi, and one for Owin. ![]() Superscribe's features are all accessed via an instance of a class that implements IRouteEngine. As a result, this section should be considered required reading before continuing to the later topics The IRouteEngine interface However, to work with Superscribe effectively and to lessen any learning curves, it is useful to understand what is going on behind the scenes. In practice you won't want to write routes using the Fluent API, as they won't look very nice and will be quite verbose instead you'll be using the simple-syntax wherever possible. Defining routes using superscribe's fluent interface
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |