diff --git a/std/http/README.md b/std/http/README.md index 26fe25bf63..459c8e2867 100644 --- a/std/http/README.md +++ b/std/http/README.md @@ -1,6 +1,23 @@ # http -A framework for creating HTTP/HTTPS server. +```typescript +import { serve } from "https://deno.land/std/http/server.ts"; +const body = new TextEncoder().encode("Hello World\n"); +const s = serve({ port: 8000 }); +console.log("http://localhost:8000/"); +for await (const req of s) { + req.respond({ body }); +} +``` + +### File Server + +A small program for serving local files over HTTP + +```sh +deno --allow-net --allow-read https://deno.land/std/http/file_server.ts +> HTTP server listening on http://0.0.0.0:4500/ +``` ## Cookie @@ -50,25 +67,3 @@ console.log("Set-Cookie:", cookieHeader); ``` **Note**: At the moment multiple `Set-Cookie` in a `Response` is not handled. - -## Example - -```typescript -import { serve } from "https://deno.land/std/http/server.ts"; -const s = serve("0.0.0.0:8000"); -const body = new TextEncoder().encode("Hello World\n"); - -for await (const req of s) { - req.respond({ body }); -} -``` - -### File Server - -A small program for serving local files over HTTP. - -Install it by using `deno install` - -```sh -deno install file_server https://deno.land/std/http/file_server.ts --allow-net --allow-read -``` diff --git a/std/manual.md b/std/manual.md index affcfd3959..d2f5f348c4 100644 --- a/std/manual.md +++ b/std/manual.md @@ -1072,10 +1072,10 @@ are. ```ts const { resources, close } = Deno; console.log(resources()); -// output like: { 0: "stdin", 1: "stdout", 2: "stderr", 3: "repl" } - -// close resource by rid -close(3); +// { 0: "stdin", 1: "stdout", 2: "stderr" } +close(0); +console.log(resources()); +// { "stdout", 2: "stderr" } ``` #### Metrics