Rest Server Overview
Listen, Route and Respond
The basic idea behind Grapevine is simple: listen for incoming http requests on a given host/port combination and route the requests to one or more methods (in your code) for processing. At least one of the methods should send a response back to the client.
Working With IHttpContext
Before anything else, one should understanding the HttpContext that gets generated from an incoming HTTP request and passed around. It encapsulates the clients incoming request, a response object for responding, a reference to the server that received the request and a collection of user-defined request-specific properties.
Creating and Registering Routes
Now that we understand what a route will be operating on, we'll explore how to create routes and the three strategies - manual, autodiscovery and hybrid - available for registering our routes with the router.
The Request Routing Lifecycle
With all the routes in place, we can discuss the journey an client request (encapsulated in IHttpContext
) takes through the registered routes to produce a response for the client and how to set up event handlers to fire before and after each request.
Managing Your Rest Server
Finally we'll cover setting up and starting the actual rest server. We'll also include such intriguing topics as logging, clustering, public folders (for static content) and event handlers for starting and stopping the server.
Miscellaneous
We'll wrap it all up with a brief overview of some of the less prominent (but no less useful) bits such as the HttpStatusCode
, HttpMethod
and ContentType
enums, the built-in port-finder and utilizing dynamic properties to maintain state between routes.