Skip to content
joongonn edited this page Dec 8, 2015 · 4 revisions

Library usage overview

The following diagram illustrates how the client application interfaces with the library.

  1. The user defines a RouteTable, mapping URL path patterns to their handlers
  2. Which the Backend uses to determine where to send a request

RouteTable

The RouteTable is basically a table of function pointers into the application space's class methods. It is constructed with a list of Endpoint instances:

    public sealed class RouteTable : IEnumerable<Endpoint>
    {
        ......
        public RouteTable(params Endpoint[] endpoints) { ...

Endpoint

The Endpoint is defined as:

    public class Endpoint
    {
        public readonly Method Method;
        public readonly Route Route;
        public readonly Func<Request, Task<HttpResponse>> Handler;

        public Endpoint(Method method, Route route, Func<Request, Task<HttpResponse>> handler)
        {
            Method = method;
            Route = route;
            Handler = handler;
        }
    }

Route

And a Route may be constructed with a pathTemplate pattern:

    public sealed class Route
    {
        ...
        public Route(string pathTemplate) {

The following pattern forms are currently supported:

  1. Literal match
  • /accounts
  1. Path variable capture
  • /products/{id}/transactions
  1. Trailing wildcard
  • /files/*

Handlers

Clone this wiki locally