raxx_static v0.8.0 Raxx.Static

Serve the contents of a directory as static content.

@static_setup Raxx.Static.setup(source: "path/to/assets")

stack =
  Raxx.Stack.new(
    [
      {Middleware.Static, @static_state}
    ],
    {MyApp, config}
  )

Use setup/1 at compile time so that files are read only once. Raxx.Static should not be used for serving large files.

Extensions

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. https://groups.google.com/forum/#!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"
  • Passing options to the middleware reads the entire source directory on every request!

Link to this section Summary

Link to this section Functions