-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (41 loc) · 1.33 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const request = require("./libs/request")
const HTTPS = 'https'
const HTTP = 'http'
const methods= {
GET: 'GET',
POST: 'POST',
PUT: 'PUT',
DELETE: 'DELETE',
PATCH: 'PATCH'
}
const get = request_type => async ({host, port, path, headers})=>{
return await request[request_type]({host, port, path, headers, method: methods.GET})
}
const post = request_type => async ({host, port, path, headers, body})=>{
return await request[request_type]({host, port, path, headers, body, method: methods.POST})
}
const put = request_type => async ({host, port, path, headers, body})=>{
return await request[request_type]({host, port, path, headers, body, method: methods.PUT})
}
const patch = request_type => async ({host, port, path, headers, body})=>{
return await request[request_type]({host, port, path, headers, body, method: methods.PATCH})
}
const del = request_type => async ({host, port, path, headers})=>{
return await request[request_type]({host, port, path, headers, method: methods.DELETE})
}
module.exports = {
https:{
get: get(HTTPS),
post: post(HTTPS),
put: put(HTTPS),
patch: patch(HTTPS),
delete: del(HTTPS)
},
http:{
get: get(HTTP),
post: post(HTTP),
put: put(HTTP),
patch: patch(HTTP),
delete: del(HTTP)
}
}