Skip to content

Commit

Permalink
chore: update README.md (denoland#11633)
Browse files Browse the repository at this point in the history
Updates "complex" example in the README.md, which used std/http
which will be phased out. Instead use newly stabilized Deno.serveHttp()
  • Loading branch information
bartlomieju committed Aug 12, 2021
1 parent b1799e6 commit 3197cad
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:https://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"));
}
}
```

Expand Down

0 comments on commit 3197cad

Please sign in to comment.