https://github.com/crowdhailer/raxx_static
Raxx middleware for serving static content.
https://github.com/crowdhailer/raxx_static
Last synced: 10 months ago
JSON representation
Raxx middleware for serving static content.
- Host: GitHub
- URL: https://github.com/crowdhailer/raxx_static
- Owner: CrowdHailer
- License: apache-2.0
- Created: 2017-11-27T21:05:54.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-10T10:20:55.000Z (over 6 years ago)
- Last Synced: 2025-03-07T06:05:45.667Z (10 months ago)
- Language: Elixir
- Homepage: https://github.com/crowdhailer/raxx
- Size: 21.5 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Raxx.Static
**[Raxx](https://github.com/crowdhailer/raxx) middleware for serving static content.**
[](https://hex.pm/packages/raxx_static)
[](https://travis-ci.org/CrowdHailer/raxx_static)
[](LICENSE)
- [Install from hex.pm](https://hex.pm/packages/raxx_static)
- [Documentation available on hexdoc](https://hexdocs.pm/raxx_static)
- [Raxx discussion on slack](https://elixir-lang.slack.com/messages/C56H3TBH8/)
## Getting Started
Add routes for static assets to any server module.
```elixir
defmodule MyApp.WWW do
def start_link(config, server_options) do
stack =
Raxx.Stack.new(
[
{Raxx.Static, source: "dir/of/public/content"}
# Other middleware
],
{MyApp.WWW.Router, config}
)
Ace.HTTP.Service.start_link(stack, server_options)
end
end
```
### Read files at compile time.
To read source files only once use `Raxx.Static.setup/1`.
This takes the same arguments as above.
```elixir
@static_setup Raxx.Static.setup(source: "dir/of/public/content")
# in stack
{Raxx.Static, @static_setup}
```