1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

docs(runtime): fix HTTP server example (#10497)

This commit is contained in:
vwkd 2021-05-06 04:47:58 +02:00 committed by GitHub
parent e64cf4eeac
commit 4f5b4f9cee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,10 +74,10 @@ There is also the `.accept()` method on the listener which can be used:
const server = Deno.listen({ port: 8080 });
while (true) {
const conn = server.accept();
if (conn) {
try {
const conn = await server.accept();
// ... handle the connection ...
} else {
} catch (err) {
// The listener has closed
break;
}
@ -122,8 +122,8 @@ await the next request. It would look something like this:
const server = Deno.listen({ port: 8080 });
while (true) {
const conn = server.accept();
if (conn) {
try {
const conn = await server.accept();
(async () => {
const httpConn = Deno.serveHttp(conn);
while (true) {
@ -136,7 +136,7 @@ while (true) {
}
}
})();
} else {
} catch (err) {
// The listener has closed
break;
}