@@ -3,53 +3,53 @@ defmodule HTTPlexWeb.APIController do
3
3
4
4
5
5
6
- @ spec index ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
6
+ @ spec index ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
7
7
def index ( conn , _params ) do
8
8
json ( conn , % { message: "Welcome to HTTPlex!" } )
9
9
end
10
10
11
- @ spec ip ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
11
+ @ spec ip ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
12
12
def ip ( conn , _params ) do
13
13
json ( conn , % { origin: format_ip ( conn . remote_ip ) } )
14
14
end
15
15
16
- @ spec user_agent ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
16
+ @ spec user_agent ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
17
17
def user_agent ( conn , _params ) do
18
18
user_agent = get_req_header ( conn , "user-agent" ) |> List . first ( )
19
19
json ( conn , % { "user-agent": user_agent } )
20
20
end
21
21
22
- @ spec headers ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
22
+ @ spec headers ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
23
23
def headers ( conn , _params ) do
24
24
json ( conn , % { headers: Map . new ( conn . req_headers ) } )
25
25
end
26
26
27
- @ spec get ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
27
+ @ spec get ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
28
28
def get ( conn , _params ) do
29
29
json ( conn , request_info ( conn ) )
30
30
end
31
31
32
- @ spec post ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
32
+ @ spec post ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
33
33
def post ( conn , _params ) do
34
34
json ( conn , request_info ( conn ) )
35
35
end
36
36
37
- @ spec put ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
37
+ @ spec put ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
38
38
def put ( conn , _params ) do
39
39
json ( conn , request_info ( conn ) )
40
40
end
41
41
42
- @ spec patch ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
42
+ @ spec patch ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
43
43
def patch ( conn , _params ) do
44
44
json ( conn , request_info ( conn ) )
45
45
end
46
46
47
- @ spec delete ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
47
+ @ spec delete ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
48
48
def delete ( conn , _params ) do
49
49
json ( conn , request_info ( conn ) )
50
50
end
51
51
52
- @ spec cache ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
52
+ @ spec cache ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
53
53
def cache ( conn , _params ) do
54
54
etag = "33a64df551425fcc55e4d42a148795d9f25f89d4"
55
55
last_modified = "Wed, 31 July 2024 07:28:00 GMT"
@@ -92,7 +92,7 @@ defmodule HTTPlexWeb.APIController do
92
92
end
93
93
end
94
94
95
- @ spec response_headers ( any ( ) , any ( ) ) :: Plug.Conn . t ( )
95
+ @ spec response_headers ( map ( ) , any ( ) ) :: Plug.Conn . t ( )
96
96
def response_headers ( conn , params ) do
97
97
conn =
98
98
Enum . reduce ( params , conn , fn { key , value } , acc ->
@@ -125,7 +125,7 @@ defmodule HTTPlexWeb.APIController do
125
125
end
126
126
end
127
127
128
- @ spec bearer ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
128
+ @ spec bearer ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
129
129
def bearer ( conn , _params ) do
130
130
case get_req_header ( conn , "authorization" ) do
131
131
[ "Bearer " <> token ] ->
@@ -421,7 +421,7 @@ defmodule HTTPlexWeb.APIController do
421
421
|> send_resp ( 200 , "<html><body><h1>Hello, World!</h1></body></html>" )
422
422
end
423
423
424
- @ spec json_response ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
424
+ @ spec json_response ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
425
425
def json_response ( conn , _params ) do
426
426
json ( conn , % { message: "This is a JSON response" } )
427
427
end
@@ -441,7 +441,7 @@ defmodule HTTPlexWeb.APIController do
441
441
|> send_resp ( 200 , String . trim ( content ) )
442
442
end
443
443
444
- @ spec xml ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
444
+ @ spec xml ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
445
445
def xml ( conn , _params ) do
446
446
conn
447
447
|> put_resp_content_type ( "application/xml" )
@@ -451,7 +451,7 @@ defmodule HTTPlexWeb.APIController do
451
451
)
452
452
end
453
453
454
- @ spec forms_post ( Plug.Conn . t ( ) , any ( ) ) :: Plug.Conn . t ( )
454
+ @ spec forms_post ( Plug.Conn . t ( ) , map ( ) ) :: Plug.Conn . t ( )
455
455
def forms_post ( conn , _params ) do
456
456
json ( conn , conn . body_params )
457
457
end
0 commit comments