Version 0 of Track

Updated 2020-05-28 09:19:46 by MJ

A work in process library for making a small web framework. Heavily inspired by the Elixir Phoenix framework request pipelining and routing

Design

  • Functional: most functions will transform a dict containing the request and response parts.
  • Composable: it should be possible to combine request dict transformers in arbitrary order. This makes it possible to pick and choose parts of the "framework" and make it easy to extend.
  • Prefix based: All defined callbacks are treated as prefixes.

Components

Server

Router

The router library takes a request dict and takes the path element an a routes list. It will then determine which route matches and call the associated prefix command with the request dict as last parameter (or without if the prefix start with !)

While matching the route, parts which start with @ or : will match anything and the matched part will be stored in the req dict as params. The difference between @ and : is that @ will also match any following slashes.

Example:

set routes {
    /ivi/:id                    ivi::handler
    /ivi/:id/:subresource       ivi::handler
    /svi/:vin                   svi::handler
    /soi/:id                    soi::handler
    /vicci/ihdcc/:code          {vicci::handler ihdcc}
    /vicci/dcc/:code            {vicci::handler dcc}
    /css/default.css            {track::asset default.css text/css}
    /                           {track::md index.md}
    /console                        {!console show}
    /exit                        {!exit}
    /vagbearer                  vagbearer::handler
    @rest                       track::debug_req
}