From 0c0e35c2e07c521a1294b750185d2f04fbd2ef32 Mon Sep 17 00:00:00 2001 From: hashrock Date: Thu, 29 Nov 2018 12:05:14 +0900 Subject: [PATCH 1/2] Update usage --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 614e530875af..b607ed881391 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,6 @@ Usage: import { serve } from "https://deno.land/x/net/http.ts"; const s = serve("0.0.0.0:8000"); for await (const req of s) { - req.respond({ body: "Hello World\n" }); + req.respond({ body: new TextEncoder().encode("Hello World\n") }); } ``` From 318c14cdff1a5c7c747dbfcbd33e9d85d649cf8d Mon Sep 17 00:00:00 2001 From: hashrock Date: Fri, 30 Nov 2018 00:22:49 +0900 Subject: [PATCH 2/2] Wrap the code example with async function --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b607ed881391..ee6009304f8d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,12 @@ Usage: ```typescript import { serve } from "https://deno.land/x/net/http.ts"; const s = serve("0.0.0.0:8000"); -for await (const req of s) { - req.respond({ body: new TextEncoder().encode("Hello World\n") }); + +async function main() { + for await (const req of s) { + req.respond({ body: new TextEncoder().encode("Hello World\n") }); + } } + +main(); ```