feat: support {App, Path} tuples in static routes#378
Open
Conversation
Allows serving static files from any dependency's priv directory
using a simple two-tuple: {AppName, "path/in/priv"}.
Usage in router:
{"/arizona/[...]", {arizona_core, "static/assets"}}
{"/assets/[...]", "static/assets"}
37779cf to
42628a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
{App, Path}tuples in static routes to serve files from any dependency's priv directoryUsage
Why
Currently Nova's static routes only resolve files from the current application's priv directory. This forces libraries to require users to copy assets into their app's priv. Phoenix/LiveView solves this by allowing deps to serve from their own priv — this brings the same capability to Nova.
The immediate use case is
arizona_coreservingarizona.min.jsdirectly, but it works for any dependency that ships static assets.Implementation
One new
parse_urlclause matching{RemotePath, {DepApp, LocalPath}}. Resolves viacode:priv_dir(DepApp)and creates the appropriatenova_file_controllerhandler — same mechanism as existing string-based static routes.Test plan
{arizona_core, "static/assets"}