Tesla.Middleware.BaseUrl (tesla v1.4.0) View Source

Set base URL for all requests.

The base URL will be prepended to request path/url only if it does not include http(s).

Example usage

defmodule MyClient do
  use Tesla

  plug Tesla.Middleware.BaseUrl, "https://example.com/foo"
end

MyClient.get("/path") # equals to GET https://example.com/foo/path
MyClient.get("path") # equals to GET https://example.com/foo/path
MyClient.get("") # equals to GET https://example.com/foo
MyClient.get("http://example.com/bar") # equals to GET http://example.com/bar