I've definitely run into issues where I need to pass an environment variable at run time, but an application that I use doesn't support the {:system, "DATABASE_URL"} or {:system, "PORT"} style environment variables that Ecto and Phoenix support.I'm curious if it would be beneficial to add support in Application.get_env/2 that when the value that returns matches {:system, var} then System.get_env(var) would be called under the hood.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/9fd6e998-04d2-4d7d-87ee-34abb16ee779%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
There has been a couple discussions on the topic either here or on the issues tracker.The consensus is that this problem needs to be solved but we are not quite sure how. The only way to support {:system, "DATABASE_URL"} in a way that it would also work for Erlang applications is by hijacking the application controller using private APIs. We could also try solve this exclusively for Elixir but then there would be gaps where it wouldn't be supported.Ecto 2.1 is trying a new approach where the value is configured using a repository callback, that's what we will try to do when Phoenix 1.3 comes out and see where it will lead us to.
On Sat, Dec 17, 2016 at 1:48 AM, Cory ODaniel <co...@coryodaniel.com> wrote:
I've definitely run into issues where I need to pass an environment variable at run time, but an application that I use doesn't support the {:system, "DATABASE_URL"} or {:system, "PORT"} style environment variables that Ecto and Phoenix support.I'm curious if it would be beneficial to add support in Application.get_env/2 that when the value that returns matches {:system, var} then System.get_env(var) would be called under the hood.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/9fd6e998-04d2-4d7d-87ee-34abb16ee779%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BOpmZ%3Ds3b2OvAH0chC9wwGL2HrRCB1v2ymbcjOzSc4BA%40mail.gmail.com.
Why not just use `Application.get_env(app_name, var_name) || System.get_env(var_name)` in your init callback? Seems much clearer to me and requires no additions to get_env.
On Sat, 17 Dec 2016 at 09:17 José Valim <jose....@plataformatec.com.br> wrote:
There has been a couple discussions on the topic either here or on the issues tracker.The consensus is that this problem needs to be solved but we are not quite sure how. The only way to support {:system, "DATABASE_URL"} in a way that it would also work for Erlang applications is by hijacking the application controller using private APIs. We could also try solve this exclusively for Elixir but then there would be gaps where it wouldn't be supported.Ecto 2.1 is trying a new approach where the value is configured using a repository callback, that's what we will try to do when Phoenix 1.3 comes out and see where it will lead us to.
On Sat, Dec 17, 2016 at 1:48 AM, Cory ODaniel <co...@coryodaniel.com> wrote:
I've definitely run into issues where I need to pass an environment variable at run time, but an application that I use doesn't support the {:system, "DATABASE_URL"} or {:system, "PORT"} style environment variables that Ecto and Phoenix support.I'm curious if it would be beneficial to add support in Application.get_env/2 that when the value that returns matches {:system, var} then System.get_env(var) would be called under the hood.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/9fd6e998-04d2-4d7d-87ee-34abb16ee779%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BOpmZ%3Ds3b2OvAH0chC9wwGL2HrRCB1v2ymbcjOzSc4BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAM-pwt7n0xP_AQDKX4Qc5DyM2u0B8K5VzEcULD5OCcKsTGaW2Q%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
defmodule HalfDome.Endpoint do
use Phoenix.Endpoint, otp_app: :half_dome
plug PlugCanonicalHost, canonical_host: System.get_env("CANONICAL_HOST")
#...
end
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/GwR7b9OVRcc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/964e79d1-2b4f-4bc4-ae75-55c18ed42538%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/964e79d1-2b4f-4bc4-ae75-55c18ed42538%40googlegroups.com.
defmodule HalfDome.Endpoint douse Phoenix.Endpoint, otp_app: :half_dome
plug :canonical_hostdefp canonical_host(conn, _opts) doopts = Plug.CanonicalHost.init(canonical_host: System.get_env("CANONICAL_HOST"))PlugCanonicalHost.call(conn, opts)endend
Application.put_env(:plug_canonical_host, :canonical_host, System.get_env("CANONICAL_HOST"))
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/dd63b674-35ed-4afe-833b-4080f197160b%40googlegroups.com.