Skip to content

Commit b953c30

Browse files
committed
Add H3llo World example
1 parent fc703d9 commit b953c30

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎examples/H3lloWorld.js‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Minimal HTTP/3 example */
2+
3+
const uWS = require('../dist/uws.js');
4+
const port = 9001;
5+
6+
/* The only difference here is that we use uWS.H3App rather than uWS.App or uWS.SSLApp.
7+
* And of course, there are no WebSockets in HTTP/3 only WebTransport (coming) */
8+
9+
const app = uWS.H3App({
10+
key_file_name: 'misc/key.pem',
11+
cert_file_name: 'misc/cert.pem',
12+
passphrase: '1234'
13+
}).get('/*', (res, req) => {
14+
res.end('H3llo World!');
15+
}).listen(port, (token) => {
16+
if (token) {
17+
console.log('Listening to port ' + port);
18+
} else {
19+
console.log('Failed to listen to port ' + port);
20+
}
21+
});

0 commit comments

Comments
 (0)