File tree Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Original file line number Diff line number Diff line change 1
1
# objective-http
2
2
Proxy classes for creating a http server
3
3
4
- ## Using
4
+ ## Server
5
+
6
+ There are all ``` Server ``` classes feature.
7
+ Your endpoints must implement ``` Endpoint ``` class interface (``` route ``` and ``` handle ``` functions).
5
8
6
9
``` javascript
7
10
const http = require (' node:http' );
@@ -40,4 +43,40 @@ new ClusteredServer(
40
43
cluster,
41
44
{workers: workers_count}
42
45
).start ();
46
+ ```
47
+
48
+ ## Client
49
+
50
+ ``` javascript
51
+ const https = require (' node:https' );
52
+ const {
53
+ OutputRequest ,
54
+ InputResponse
55
+ } = require (' objective-http' ).client ;
56
+
57
+
58
+ const response = await new OutputRequest (
59
+ https,
60
+ new InputResponse (),
61
+ {
62
+ url: ' https://example.com' ,
63
+ method: ' POST' ,
64
+ body: ' test body'
65
+ })
66
+ .send ();
67
+
68
+ console .log (response .body ().toString ());
69
+
70
+ // or
71
+
72
+ const request = new OutputRequest (https, new InputResponse ());
73
+
74
+ const otherResponse = await (request
75
+ .copy ({
76
+ url: ' https://example.com' ,
77
+ method: ' POST' ,
78
+ body: ' test body'
79
+ }))
80
+ .send ()
81
+
43
82
```
You can’t perform that action at this time.
0 commit comments