diff options
| author | Ryan Dahl <ry@tinyclouds.org> | 2019-02-19 12:38:19 -0500 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2019-02-19 13:18:41 -0500 |
| commit | d63a2e02246c0eb2ee6258b8fc32bbd0f9378567 (patch) | |
| tree | 81b4019b47cc645887d738664578d2b2ff1facd3 /http/README.md | |
| parent | a5a48ce84d255c8af57feb4b6a7f7ef607d16ee0 (diff) | |
Revert "Redesign of http server module (denoland/deno_std#188)"
We need to consider the API changes here more carefully.
This reverts commit da188a7d30cbf71317b46015ee63a06437c09aeb.
and commit 8569f15207bdc12c2c8ca81e9d020955be54918b.
Original: https://github.com/denoland/deno_std/commit/57c9176b19bf4f4580466e088c249cbe9b145119
Diffstat (limited to 'http/README.md')
| -rw-r--r-- | http/README.md | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/http/README.md b/http/README.md index 67c578f31..2c9a90853 100644 --- a/http/README.md +++ b/http/README.md @@ -5,22 +5,13 @@ A framework for creating HTTP/HTTPS server. ## Example ```typescript -import { createServer } from "https://deno.land/x/http/server.ts"; -import { encode } from "https://deno.land/x/strings/strings.ts"; +import { serve } from "https://deno.land/x/http/server.ts"; +const s = serve("0.0.0.0:8000"); async function main() { - const server = createServer(); - server.handle("/", async (req, res) => { - await res.respond({ - status: 200, - body: encode("ok") - }); - }); - server.handle(new RegExp("/foo/(?<id>.+)"), async (req, res) => { - const { id } = req.match.groups; - await res.respondJson({ id }); - }); - server.listen("127.0.0.1:8080"); + for await (const req of s) { + req.respond({ body: new TextEncoder().encode("Hello World\n") }); + } } main(); |
