-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathphue.q
38 lines (31 loc) · 884 Bytes
/
phue.q
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
/ to be loaded by lights.q, .config needs to be set prior
info:{-1"[",string[.z.Z],"][info] ",x;};
debug:{if[system"e";-1"[",string[.z.Z],"][debug] ",x];};
.z.pw:{(.config.user~string x)&.config.pass~y};
GET:{[x]
r:(`$":http://",.config.host) p:"GET /api/",.config.apikey,"/",x,"\r\n\r\n";
debug p,r;
:.j.k ("\r\n\r\n" vs r)[1];
}
PUT:{[x;y]
p:"PUT /api/",.config.apikey,"/",x,"\r\n",
"Content-Length: ",string[count s],"\r\n",
"Host: ",.config.host,"\r\n\r\n",s:.j.j y;
r:(`$":http://",.config.host) p;
debug p,"\r\n",r;
:r;
}
POST:{[x;y]
p:"POST /api/",.config.apikey,"/",x,"\r\n",
"Content-Length: ",string[count s],"\r\n",
"Host: ",.config.host,"\r\n\r\n",s:.j.j y;
r:(`$":http://",.config.host) p;
debug p,"\r\n",r;
:r;
}
DELETE:{[x]
p:"DELETE /api/",.config.apikey,"/",x,"\r\n";
r:(`$":http://",.config.host) p;
debug p,r;
:r;
}