CrowdHailer / raxx

Interface for HTTP webservers, frameworks and clients
https://hexdocs.pm/raxx
Apache License 2.0
402 stars 29 forks source link

Trying to generalise functionality to make a static file server #14

Closed CrowdHailer closed 7 years ago

CrowdHailer commented 7 years ago

Implement a Raxx endpoint that serves a folder of static content.

The server reads all the content at compile time. It should assume a bunch of default.

defmodule Assets do
  use Raxx.Static
  # This assumes the files are in the directory `./static` and includes all of them.
  # options will include pointing to a different directory or what files to exclude
end

The current tests fail once a second file is included. in this case site.css it seams that the pattern match is not being unquoted as I expected. I am doubly confused because the match is not catching all requests because the 404 test is passing.

Cloning the static branch at this point has one failing test this is what needs fixing before merging.

CrowdHailer commented 7 years ago

tests are now passing. The API is somewhat different to what was suggested above. The most terse is now as follows.

defmodule SingleFile do
  require Raxx.Static

  dir = "./static"
  Raxx.Static.serve_dir(dir)
end