quilt dispatch language - StoneyJackson/quilt GitHub Wiki

(Very rough draft; hack away!)

Reference material

Overview

The dispatcher inspects elements of a request (its URI, its headers, maybe even its body), and identifies the quilt document to handle the request. Additionally, it may be desirable to allow the processor to pass variables to the Quilt document, thus parameterizing the Quilt document. These might include URIs to content.

Elements of a Request

  • uri
    • scheme
    • authority
      • domain_name
      • port
      • ip
    • path
    • fragment
    • query_string
  • header
  • method

Accessing request elements

port
header[_key_]
method

Dispatch rules

If all the above conditions match, load the URI following => with the specified, space-delimited, named parameters. \1 is a back-reference to the first grouping match in the above regular expressions. Named groups are also possible via (?P...), and back-referenced as \g.

domain_name =^github.com$     /* domain name exists and is github.com */
header[_gh_sess] !^$          /* header _gh_sess exists is not empty */
path =^/([^/]*)/.*$           /* path exists and begins with /accounts/ */
=> /\1/pattern.quilt (content_base=/content/\1 css_base=/css/\1)

Operators are based on Apache rewrite rule syntax. Regular expressions grouping and back-referencing are based on Python syntax.

Use Cases

  1. User maps the site index to a specific Quilt (Default action if no rules match)
  2. User directly maps quilts to URIs EX. [Server_Path]/home => [Server_Path]/home.qlt
  3. User wants to check for authentication (Check for a certain cookie, could this be a conditional within the quilt?)
  4. User wants a specific Quilt to be selected for specific dates or times
  5. User wants a specific Quilt for each browser
  6. User has a parameterized Quilt
⚠️ **GitHub.com Fallback** ⚠️