tokumei v0.9.1 Raxx.Static View Source

Serve the contents of a directory as static content.

defmodule MyApp do
  use Raxx.Server
  use Raxx.Router, [
    {%{method: :GET, path: []}, MyApp.HomePage}
  use Raxx.Static, "./public"

*If the path given to Raxx.Static is relative, it will be expanded relative to the file using Raxx.Static

Using Raxx.Static writes a route for each file in the given directory. If a request does not match any of these paths it will be passed up the stack. In this example if a request does not match content in the public dir it will then be passed to the router


Proposed extensions to Raxx.Static:

  • Check accept header and return content error when appropriate
  • gzip encoding plug doesnt actually gzip it just assumes a file named path <>.gz gzip is assumed false by default, say true to generate gz from contents or path modification if zipped exists.!topic/elixir-lang-talk/RL-qWWx9ILE
  • cache control time
  • Etags
  • filtered reading of a file
  • set a maximum size of file to bundle into the code.
  • static_content(content, mime)
  • check trying to serve root file
  • use plug semantics of {:app, path/in/priv} or “/binary/absoulte” or “./binary/from/file”