@@ -5,15 +5,11 @@ require "http/client"
5
5
module Teletube
6
6
class Http
7
7
def initialize (config : Teletube ::Config )
8
- uri = URI .parse(config.endpoint)
9
- @http = HTTP ::Client .new(
10
- host: uri.host || " localhost" ,
11
- port: uri.port || 500 ,
12
- tls: uri.scheme == " https"
13
- )
8
+ @http = HTTP ::Client .new(uri: URI .parse(config.endpoint))
14
9
@headers = HTTP ::Headers .new
15
10
@headers [" Authorization" ] = " Token #{ config.token } "
16
11
@headers [" Accept" ] = " application/json,*/*"
12
+ @headers [" Content-Type" ] = " application/json; charset=utf-8"
17
13
end
18
14
19
15
def get (path : String )
@@ -25,7 +21,15 @@ module Teletube
25
21
end
26
22
27
23
def post (path : String , params : Hash (String , String ))
28
- @http .post(path: path, headers: @headers , body: HTTP ::Params .encode(params))
24
+ @http .post(path: path, headers: @headers , body: params.to_json)
25
+ end
26
+
27
+ def patch (path : String , params : Hash (String , String ))
28
+ @http .patch(path: path, headers: @headers , body: params.to_json)
29
+ end
30
+
31
+ def delete (path : String )
32
+ @http .delete(path: path, headers: @headers )
29
33
end
30
34
end
31
35
end
0 commit comments