hocon_url_resolver v0.1.0 HoconUrlResolver View Source

This module is responsible for loading resources from the internet.

It uses the HTTPoison client to fetch the configuration. It is used with Hocon to include URL configuration by using the module with the Keyword :url_resolver:

Example

iex> Hocon.decode( ~s( b : { include url("https://raw.githubusercontent.com/zookzook/hocon-url-resolver/master/test/data/config-1.conf") }), url_resolver: HoconUrlResolver )
{:ok, %{"b" => %{"a" => "The answer is 42"}}}

Link to this section Summary

Functions

Returns true if resource exists.

Returns a tuple with the content of the resource

Link to this section Functions

Returns true if resource exists.

Example

iex> HoconUrlResolver.exists?("https://raw.githubusercontent.com/zookzook/hocon-url-resolver/master/test/data/config-2.conf")
false
iex> HoconUrlResolver.exists?("https://raw.githubusercontent.com/zookzook/hocon-url-resolver/master/test/data/config-1.conf")
true
Link to this function

load(url)

View Source
load(Path.t()) :: {:ok, binary()} | {:error, File.posix()}

Returns a tuple with the content of the resource

Example

iex> HoconUrlResolver.load("https://raw.githubusercontent.com/zookzook/hocon-url-resolver/master/test/data/config-2.conf")
{:error, "not found"}
iex> HoconUrlResolver.load("https://raw.githubusercontent.com/zookzook/hocon-url-resolver/master/test/data/config-1.conf")
{:ok, "{\n  a : \"The answer is 42\"\n}"}