2015-09-17 App entry point

I am trying to make general routing / entry point for different kinds of app usage. There are a lot of app entry-points, including: full apps, http-requests, widgets. When looking at different use cases, there are two kinds of requests:

  • single, one-off requests, like http, api-calls, etc.
  • reactive request, like interactive apps and widgets, or subscribed resources

Also note that several entry points can be active at the same time, ie. widgets within a page or parallel http-requests.

The initial use cases for the router will be:

  • Fullpage react-html apps
  • HTML5-widgets
  • Static html generation (http-requests)
  • REST-api

Some likely future routing requirements might include:

  • Command line arguments
  • RPC, including p2p-rpc
  • WebGL or canvas image generation, and interactive apps
  • React-native apps

My current draft of what the structure would be is:

A route is defined by: (route "path" f) where f is a function that takes an options-object as parameter, and returns a result object. options include

  • :reactive – whether the result will be shown reactively, or single run
  • :id – identifier for route execution, data specific to this execution should be altered in (db (:id options))
  • :args data specific to this execution
  • :path path for this specific execution
  • Probably later: :accept map of content-type/priorities, ie: {"text/html" 0.9 "text/*" 0.1}
  • Probably later: :auth authentication

result is unwrapped async/atom and can include:

  • :type can be :html, or content-type-string if :content is raw data, probably later also :clj :json, … later on.
  • one of
    • :content
    • :html + :title and optionally :css
  • Probably later: :caching