Skip to content

Commit eb2e7fe

Browse files
Merge pull request #15 from volatilization/feature/client-side
update README.md with Client usage
2 parents 06b8ae0 + 4c2f842 commit eb2e7fe

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# objective-http
22
Proxy 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
710
const 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
```

0 commit comments

Comments
 (0)