5 Days of Simple.Web: Getting Started
- Getting started
- Resource handling
- Content negotiation
- Hypermedia as the engine of application state (HATEOAS)
- OWIN middleware
Simple.Web is intended to be exactly that – Simple! Let’s see how easy it is to get started.
1. Create a new Console Project
Let’s create a console project to bootstrap our example. I’m using MonoDevelop here to show Simple.Web is just as fantastic on Mono as .NET. If you also want to use MonoDevelop then I’d recommend installing the NuGet add-in.
2. Install NuGet packages
I’m going to pick the new self-hosting package, it will bring in all the dependencies I need.
Note: As Katana v2 is only available as a pre-release package Simple.Web.Hosting.Self depends on a custom NuGet source; furthermore a custom RTM build of ‘dev’ branch ensuring mono-compatibility. To use Simple.Web.Hosting.Self add https://www.myget.org/F/katana-mono to your available package sources.
1 2 3 4 5 6 7 8 9 10 11 12
4. Create a resource
For the sake of simplicity I have chosen not to return a model (and thus use content negotiation) and instead inherit Simple.Web “OutputBehaviour”
IOutput<RawHtml> that will simple render the contents of the string into the response stream; together with a 200 OK HTTP response code we’re done!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
5. Run & Browse
Let’s hit F5/CMD-Enter to run and browse to the default address of http://localhost:3333.
Too Simple? Bit disappointed? Sorry about that ;–)