mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
docs(runtime): fix HTTP server example (#10497)
This commit is contained in:
parent
e64cf4eeac
commit
4f5b4f9cee
1 changed files with 6 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue