elixir-maru / maru

Elixir RESTful Framework
https://maru.readme.io
BSD 3-Clause "New" or "Revised" License
1.32k stars 85 forks source link

Partial parsing of configuration #82

Closed jalcine closed 6 years ago

jalcine commented 7 years ago

I've noticed that the port number is parsed using Confex but not the host name value. Is this intentional?

jalcine commented 7 years ago

Stacktrace:

** (Mix) Could not start application maru: Maru.start(:normal, []) returned an error: an exception was raised:
    ** (FunctionClauseError) no function clause matching in String.to_charlist/1
        (elixir) lib/string.ex:1834: String.to_charlist({:system, :bitstring, "API_HOST", "0.0.0.0"})
        (maru) lib/maru/supervisor.ex:48: Maru.Supervisor.to_ip/1
        (maru) lib/maru/supervisor.ex:38: Maru.Supervisor.endpoint_spec/3
        (maru) lib/maru/supervisor.ex:18: anonymous fn/4 in Maru.Supervisor.init/1
        (elixir) lib/enum.ex:1811: Enum."-reduce/3-lists^foldl/2-0-"/3
        (maru) lib/maru/supervisor.ex:16: anonymous fn/2 in Maru.Supervisor.init/1
        (elixir) lib/enum.ex:1811: Enum."-reduce/3-lists^foldl/2-0-"/3
        (maru) lib/maru/supervisor.ex:15: Maru.Supervisor.init/1
falood commented 7 years ago

Hi @jalcine confex is a soft depend of maru, that means if it is added in your deps list, maru will use it, if you haven't added it, maru will treat all the config values as tring. so I guess adding confex to your deps list in the mix.exs file will resolve your problem 🙂

jalcine commented 7 years ago

Understood.

Something like this has to be in the README. I can open a pull request for that.

falood commented 7 years ago

It will be great if you can do the help!

jalcine commented 7 years ago

Just noticed that this didn't answer the question, though. Two things have to be done: