-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a feature for declaring a custom static paths ("public/" alternatives) #661
Comments
@rssdev10 I don't fully understand the use case so maybe you can provide an example of what you're trying to serve. I can think of a few approaches but without understanding exactly what you want to achieve, I don't know what's best. But before we dive into that, it's worth noting that the approach you propose would not be recommended for many files, as you're registering a route for each static file. Now for the options: 1/ in the upcoming Genie 6 (currently in the # Genie 6 code
route("/components/*") do params
serve_static_file(joinpath(your_components_folder, params["_"]))
end The route part corresponding to the 2/ As is, Genie already first checks if the path of a request is a static file. So if you put them inside the 3/ You could add a router hook - this would cause Genie to automatically invoke the function you define before running the route matching code. In your hook you could process the request and return the static file response if it's a match (this might also work better in v6 due to recent changes). What do you think? What makes more sense for your use case? I can take a closer look. |
Thanks, the case with The case with the custom location of the public path happened when we used Genie by components. In this case, we don't have a typical set of directories in the project. And our static files are in different locations. The case with multiple static public paths can also be useful if we have some different groups of files. Other case with a custom static path - use the webpack or something like that to implement the frontend. As for the backport to Genie 5, I can check it out next week. |
*
paths
*
paths
Use case. I have a REST service and want to use some Genie components. But I want to have my own project structure and keep in some convenient place for maintenance some static files that should be publicly available.
This function can be implemented in two ways: by implementing a method
static_path( url_path, local_directory)
or by means of allowing wildcard segments where I can specify a dynamic part of theurl_path
.The workaround is ugly now, but it works:
The text was updated successfully, but these errors were encountered: