Skip to content

Commit

Permalink
curl.ts example with reference in manual (denoland#3161)
Browse files Browse the repository at this point in the history
  • Loading branch information
hartror authored and ry committed Oct 21, 2019
1 parent 4e88ba9 commit 27cd2c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions std/examples/README.md
Expand Up @@ -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

```
Expand Down
8 changes: 8 additions & 0 deletions 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);
4 changes: 2 additions & 2 deletions website/manual.md
Expand Up @@ -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
Expand Down

0 comments on commit 27cd2c9

Please sign in to comment.