webdavex v0.1.0 Webdavex View Source

WebDAV client for elixir applications. See Webdavex.Client.

Refer to Webdavex.Config for detailed information on available options.

Examples

General usage

defmodule MyClient
  use Webdavex, base_url: "https://webdav.com/my_app"
end

MyClient.get("images/foobar.png")
{:ok, ...}

Dynamic config

In order to change configuration during runtime you can wrap a client in Agent and override config/0 to fetch data from its state.

defmodule MyClient do
  use Agent
  use Webdavex, base_url: "https://webdav.com"

  def start_link do
    Agent.start_link(fn -> @config end, name: __MODULE__)
  end

  def update_config(map) do
    Agent.update(__MODULE__, Webdavex.Config.new(map))
  end

  def config do
    Agent.get(__MODULE__, fn config -> config end)
  end
end

{:ok, _pid} = MyClient.start_link()
MyClient.update_config(%{base_url: "http://host", headers: [{"Foo", "bar}]})

MyClient.get("images/foobar.png")
{:ok, ...}