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

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

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