A simple cli to send http requests.
I created req mainly to use it with Rofi. At home, I can control domotics directly from Rofi.
Check the Rofi section below.
Use precompiled versions in releases page
or
go get -u github.com/itsjimi/req
First of all, you need to create a .req.json
in your home directory.
This is the most common .req.json
.
[
{
"name": "Get first post",
"url": "https://jsonplaceholder.typicode.com/posts/1",
"method": "GET"
}
]
You can list all of available requests by running.
req list
In our case we have one element displayed.
Get first post
You can run one or multiple requests by using run command.
req run "Get first post"
The result is displayed on terminal.
{
"userId": 1,
"id": 1,
"title": "...",
"body": "..."
}
By default, .req.json must be in your home directory.
[
{
"name": "Get first post",
"url": "https://jsonplaceholder.typicode.com/posts/1",
"method": "GET",
"output": "echo \"Title: {{.title}}\nBody: {{.body}}\""
},
{
"name": "Create post",
"url": "https://jsonplaceholder.typicode.com/posts",
"method": "POST",
"headers": [
"Content-type: application/json; charset=UTF-8"
],
"body": {
"title": "foo",
"body": "bar",
"userId": 1
}
}
]
output
exec commands with bash and use go template to replace variables.
- All commands can use
--help
or-h
to display its specific help. - All commands can use
--config
or-c
to use a custom.json
path. (By default req use a.req.json
in your home directory)
Display helper
req help
Display version req using SemVer.
req version
Display list of .req.json
requests names (each separated by \n
).
req list
Send one or multiple requests and display results.
Note: You can use --silent or -s to display nothing.
req run <request name> [other request name] [...]
Req can be used in rofi with the rofi-req.sh script.
Feel free to fork and make pull requests.