Phillipp

Phillipp

Configure Plug.Static at runtime

Hey,

is there a way to configure Plug.Static at runtime (right after boot)?

I have a usecase where the location of the files and the desired request path (:from and :at options) is only known after startup.

Marked As Solved

evadne

evadne

This is going to be complicated because Plug.Static uses pattern matching to only match against particular from / at values. I guess you could write a custom plug that makes its decisions dynamically and eat the performance loss.

Also Liked

Phillipp

Phillipp

Performance is not a big deal here. So I might look into building my own version of Plug.Static.

EDIT: Seems like it would be enough to create a wrapper plug that calls Plug.Static.call/2 with the conn and the dynamically created options.

Last Post!

LostKobrakai

LostKobrakai

I’m wondering if you called Plug.Static.init/1 still. The opts for call/2 are not always the same data passed on the plug call.

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement