We’ll start from my previous post with a single console application with a self-hosted OWIN instance.
The goal here is to provide a routing system so that we can route our application in different section. I could use something like WebAPI but the routing and the application itself are tightly linked.
I’m going to use a nice tool called Superscribe that allow to do routing. It’s Graph based routing but it should be simple enough for us to hook it up and create routes.
Installing Superscribe
Well, we’ll open up the Package Manager Console again and run the following command:
1 | Install-Package Superscribe.Owin |
This should install all the proper dependencies to have our routing going.
Modifying our Startup.cs to include Superscribe
First thing first, let’s get rid of this silly WelcomePage we created in the previous post. Boom. Gone.
Let’s create some basic structure to handle our routes.
1 | using Microsoft.Owin; |
So this code basically create all the necessary plumbing for Superscribe to handle our requests.
Creating our routes
So we now have a route engine to work with. So let’s first create a handler for the default “/” URL.
We’ll also create a route for “/welcome” to use our default WelcomePage that we had earlier (just for demo purpose).
We’ll also create a route for “/Home” that will return a plain text (for the moment).
Here’s what it looks like:
1 | using Microsoft.Owin; |
That was simple.
Basically, we build a simple pipeline to an OWIN middleware.
What about NancyFX with Superscribe after?