Tesla.Middleware.BaseUrl (tesla v1.5.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).

Examples

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