summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-08-12 10:19:02 +0200
committerGitHub <noreply@github.com>2021-08-12 10:19:02 +0200
commit3197cad0f83d921b42dc79413836ff9e0efeaa75 (patch)
tree2ca7f34144274540fbe096ac240cd55368a58e3e /README.md
parentb1799e67715b003d8b8ec0648151d1c3b77feb0a (diff)
chore: update README.md (#11633)
Updates "complex" example in the README.md, which used std/http which will be phased out. Instead use newly stabilized Deno.serveHttp()
Diffstat (limited to 'README.md')
-rw-r--r--README.md14
1 files changed, 10 insertions, 4 deletions
diff --git a/README.md b/README.md
index 379721a56..f5ac6f1ee 100644
--- a/README.md
+++ b/README.md
@@ -72,11 +72,17 @@ deno run https://deno.land/std/examples/welcome.ts
Or a more complex one:
```ts
-import { serve } from "https://deno.land/std/http/server.ts";
-const s = serve({ port: 8000 });
+const listener = Deno.listen({ port: 8000 });
console.log("http://localhost:8000/");
-for await (const req of s) {
- req.respond({ body: "Hello World\n" });
+
+for await (const conn of listener) {
+ serve(conn);
+}
+
+async function serve(conn: Deno.Conn) {
+ for await (const { respondWith } of Deno.serveHttp(conn)) {
+ respondWith(new Response("Hello world"));
+ }
}
```