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 11# objective-http
22Proxy classes for creating a http server
33
4- ## Using
4+ ## Server
5+
6+ There are all ``` Server ``` classes feature.
7+ Your endpoints must implement ``` Endpoint ``` class interface (``` route ``` and ``` handle ``` functions).
58
69``` javascript
710const http = require (' node:http' );
@@ -40,4 +43,40 @@ new ClusteredServer(
4043 cluster,
4144 {workers: workers_count}
4245).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+
4382```
You can’t perform that action at this time.
0 commit comments