1
1
defmodule Sentry.HTTPClient do
2
2
@ moduledoc """
3
3
Specifies the API for using a custom HTTP Client.
4
+
5
+ The default HTTP client is `Sentry.HackneyClient`
6
+
7
+ To configure a different HTTP client, implement the `Sentry.HTTPClient` behaviour and
8
+ change the `:client` configuration:
9
+
10
+ config :sentry,
11
+ client: MyHTTPClient
4
12
"""
5
13
6
14
@ type headers :: [ { String . t ( ) , String . t ( ) } ]
@@ -11,44 +19,3 @@ defmodule Sentry.HTTPClient do
11
19
{ :ok , status :: pos_integer , headers , body :: String . t ( ) }
12
20
| { :error , term }
13
21
end
14
-
15
- defmodule Sentry.HackneyClient do
16
- @ behaviour Sentry.HTTPClient
17
-
18
- @ moduledoc """
19
- The built-in HTTP client.
20
- """
21
-
22
- @ hackney_pool_name :sentry_pool
23
-
24
- def child_spec do
25
- unless Code . ensure_loaded? ( :hackney ) do
26
- raise """
27
- cannot start Sentry.HackneyClient because :hackney is not available.
28
- Please make sure to add hackney as a dependency:
29
-
30
- {:hackney, "~> 1.8"}
31
- """
32
- end
33
-
34
- Application . ensure_all_started ( :hackney )
35
-
36
- :hackney_pool . child_spec (
37
- @ hackney_pool_name ,
38
- timeout: Sentry.Config . hackney_timeout ( ) ,
39
- max_connections: Sentry.Config . max_hackney_connections ( )
40
- )
41
- end
42
-
43
- def post ( url , headers , body ) do
44
- hackney_opts =
45
- Sentry.Config . hackney_opts ( )
46
- |> Keyword . put_new ( :pool , @ hackney_pool_name )
47
-
48
- with { :ok , status , headers , client } <-
49
- :hackney . request ( :post , url , headers , body , hackney_opts ) ,
50
- { :ok , body } <- :hackney . body ( client ) do
51
- { :ok , status , headers , body }
52
- end
53
- end
54
- end
0 commit comments