aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: de62dc616409fbe6cf91c39075ccb81394768ca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# rest-run
## Postman? Never heard of it! rest-run is the only REST API client you will ever need! 

### Dependencies

* Ranger file manager
* HTTPie
* esh template engine

### Instalation

If you have GNU Make installed run a
```sh
make install
```

Otherwise just copy the rest-run script to some directory on your $PATH

### Usage

```sh
# pipe JSON body to rest-run
cat /tmp/body.json | rest-run http://localhost:8080/api/path --body stdin

# create a PUT request, the default editor will be called to compose the request body
rest-run PUT http://localhost:8080/api/resource

# replay last request according to the API path, skip editting request body
rest-run PUT http://localhost:8080/api/resource -b last -ne

# pick request response from history according to the API path and read it with a pager
rest-run PUT http://localhost:8080/api/resource -r last -p
```

###### Positional arguments

You must provide the API URL. An HTTP verb preceding it is accepted if present.

###### Options

* -x|--method     HTTP Method
* -b|--body       Request body source, must be one of the following options:
  * default - create a request body using the default editor
  * last    - use the last request
  * history - pick from the request history
  * stdin   - reads from piped input
* -r|--response   Request response handling, must be one of the following options:
  * default - store the request on cache
  * last    - read last request, skip request
  * history - pick from the response history, skip request
* -ne|--no-edit   Skip request editting. Ignored when --body is set to default
* -h|--header     Header string. Ex: "Authorization: Bearer 123"
* -p|--paginate   Paginate request response

rest-run parses your request body with a simple template engine called esh. You can embed shell scripts/commands in your request file surrouning it with <% my-command %> or <%= $MY_ENV_VARIABLE %>

Example:
```sh
  echo '{
    "username": "<%= $USER %>",
    "device": "<%= $HOSTNAME %>",
    "created_at": "<% date +"%FT%T.000Z" %>",
    "password": 123
  }' | rest-run POST https://postman-echo.com/post
```