debianize-mobilizon/lib/service/http/webfinger_client.ex
Thomas Citharel 5ac02bae5d
Use runtime configuration for HTTP clients user-agent
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2021-04-12 12:01:49 +02:00

33 lines
690 B
Elixir

defmodule Mobilizon.Service.HTTP.WebfingerClient do
@moduledoc """
Tesla HTTP Basic Client
with JSON middleware
"""
use Tesla
alias Mobilizon.Config
@default_opts [
recv_timeout: 20_000
]
adapter(Tesla.Adapter.Hackney, @default_opts)
plug(Tesla.Middleware.FollowRedirects)
plug(Tesla.Middleware.Timeout, timeout: 10_000)
plug(Tesla.Middleware.Headers, [
{"User-Agent", Config.instance_user_agent()},
{"Accept", "application/json, application/activity+json, application/jrd+json"}
])
plug(Tesla.Middleware.JSON,
decode_content_types: [
"application/jrd+json",
"application/json",
"application/activity+json"
]
)
end