2020-10-21 10:42:04 +02:00
|
|
|
defmodule Mobilizon.Service.HTTP.WebfingerClient do
|
|
|
|
@moduledoc """
|
|
|
|
Tesla HTTP Basic Client
|
|
|
|
with JSON middleware
|
|
|
|
"""
|
|
|
|
|
|
|
|
use Tesla
|
|
|
|
alias Mobilizon.Config
|
2024-02-09 12:13:22 +01:00
|
|
|
import Mobilizon.Service.HTTP.Utils, only: [get_tls_config: 0]
|
2020-10-21 10:42:04 +02:00
|
|
|
|
|
|
|
@default_opts [
|
|
|
|
recv_timeout: 20_000
|
|
|
|
]
|
|
|
|
|
2024-02-09 12:13:22 +01:00
|
|
|
adapter(Tesla.Adapter.Hackney, Keyword.merge([ssl_options: get_tls_config()], @default_opts))
|
2020-10-21 10:42:04 +02:00
|
|
|
|
|
|
|
plug(Tesla.Middleware.FollowRedirects)
|
|
|
|
|
|
|
|
plug(Tesla.Middleware.Timeout, timeout: 10_000)
|
|
|
|
|
|
|
|
plug(Tesla.Middleware.Headers, [
|
2021-04-09 10:43:45 +02:00
|
|
|
{"User-Agent", Config.instance_user_agent()},
|
2020-10-21 10:42:04 +02:00
|
|
|
{"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
|