mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 20:38:55 +00:00
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()
This commit is contained in:
parent
b1799e6771
commit
3197cad0f8
14
README.md
14
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"));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user