summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--std/examples/README.md6
-rw-r--r--std/examples/curl.ts8
-rw-r--r--website/manual.md4
3 files changed, 16 insertions, 2 deletions
diff --git a/std/examples/README.md b/std/examples/README.md
index e6102a843..14f101244 100644
--- a/std/examples/README.md
+++ b/std/examples/README.md
@@ -37,6 +37,12 @@ catj file1.json file2.json
echo example.json | catj -
```
+### curl - print the contents of a url to standard output
+
+```shell
+deno --allow-net=deno.land https://deno.land/std/examples/curl.ts https://deno.land/
+```
+
### gist - easily create and upload Gists
```
diff --git a/std/examples/curl.ts b/std/examples/curl.ts
new file mode 100644
index 000000000..04dd9d601
--- /dev/null
+++ b/std/examples/curl.ts
@@ -0,0 +1,8 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+async function curl(url: string): Promise<void> {
+ const res = await fetch(url);
+ await Deno.copy(Deno.stdout, res.body);
+}
+
+await curl(Deno.args[1]);
+Deno.exit(0);
diff --git a/website/manual.md b/website/manual.md
index ec5612372..bb75114c4 100644
--- a/website/manual.md
+++ b/website/manual.md
@@ -421,11 +421,11 @@ $ deno --allow-read=/etc https://deno.land/std/examples/cat.ts /etc/passwd
This is an example to restrict host.
```ts
-const result = await fetch("https://deno.land/std/examples/echo_server.ts");
+const result = await fetch("https://deno.land/");
```
```shell
-$ deno --allow-net=deno.land allow-net-whitelist-example.ts
+$ deno --allow-net=deno.land https://deno.land/std/examples/curl.ts https://deno.land/
```
### Run subprocess