Skip to content

aminnairi/gouache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

98 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ–ŒοΈ gouache

Create HTTP requests from files and run them right from your terminal

Note

The name of this library, gouache, pronounced /Ι‘wɑːʃ/, is a french word representing a type of paint that can react to water to update or create a new painting.

πŸ€” Usage

Create a new HTTP request.

touch index.http

Fill in the details of your request.

GET /users HTTP/2
Host: https://jsonplaceholder.typicode.com
Accept: application/json

Install the binary as a global command.

go install github.com/aminnairi/gouache

Run your request.

gouache request --with-status --with-headers --with-body index.http
HTTP/2 200 OK
Server: cloudflare
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Cache-Control: max-age=43200
[
  {
    "id": 1,
    "name": "Leanne Graham",
    "username": "Bret",
    "email": "[email protected]",
    "address": {
      "street": "Kulas Light",
      "suite": "Apt. 556",
      "city": "Gwenborough",
      "zipcode": "92998-3874",
      "geo": {
        "lat": "-37.3159",
        "lng": "81.1496"
      }
    },
...

✨ Features

  • Write HTTP requests in a friendly format
  • It's just HTTP protocol and nothing else
  • Run requests right from your terminal
  • Run all requests from a folder recursively
  • Generate request files in an interactive or programmatic way

πŸƒ Installation

Note

This commands needs to be run inside of a terminal with access to the go binary.

go install github.com/aminnairi/gouache

Warning

You should have the path to go installed binaries already setup in order for your terminal to have access to this program.

πŸ‘‹ Uninstallation

Note

The go binary does not have a way to uninstall a previously installed package, but all it does is create a folder and download the sources in that folder.

rm -rf $(which gouache)

❓ Documentation

Request

Provide an HTTP request from a file

Important

If you are unsure of what the HTTP protocol is, here is a detailed article from the Mozilla Developers Network website that explains it well.

touch get.http
GET /users HTTP/2
Host: https://jsonplaceholder.typicode.com/users

Warning

There should only be one HTTP request per *.http file.

gouache request get.http

Display the status line of the response

gouache request --with-status get.http
# or
gouache request -s get.http

Display the headers of the response

gouache request --with-headers get.http
# or
gouache request -H get.http

Display the body of the request

gouache request --with-body get.http
# or
gouache request -b get.http

Send a POST request

touch post.http
POST /users HTTP/2
Host: https://jsonplaceholder.typicode.com/users
Content-Type: application/json

{
  "id": 11,
  "email": "[email protected]"
}
gouache request post.http

Send a PATCH request

touch patch.http
PATCH /users/10 HTTP/2
Host: https://jsonplaceholder.typicode.com/users
Content-Type: application/json

{
  "email": "[email protected]"
}
gouache request patch.http

Send a PUT request

touch put.http
PUT /users/10 HTTP/2
Host: https://jsonplaceholder.typicode.com/users
Content-Type: application/json

{
  "email": "[email protected]"
}
gouache request --with-status put.http

Send a DELETE request

touch delete.http
DELETE /users HTTP/2
Host: https://jsonplaceholder.typicode.com/users
Content-Type: application/json

{
  "id": 10,
  "email": "[email protected]"
}
gouache request delete.http

Run all requests from a folder recursively

mkdir requests
touch requests/users.http
GET /users HTTP/2
Host: https://jsonplaceholder.typicode.com
touch requests/posts.http
GET /posts HTTP/2
Host: https://jsonplaceholder.typicode.com
mkdir requests/posts
touch requests/posts/first.http
GET /posts/1 HTTP/2
Host: https://jsonplaceholder.typicode.com
gouache request --with-status requests

Generate

Generate a request

gouache generate get.http \
  --method GET \
  --path /users \
  --url https://jsonplaceholder.typicode.com
# or
gouache generate get.http \
  -m GET \
  -p /users \
  -u https://jsonplaceholder.typicode.com

Tip

Only providing one of the following: method, path or host or the path to the generated HTTP request will trigger the interactive mode asking you for the remaining informations.

Generate a request with a body

gouache generate post.http \
  --method GET \
  --path /users \
  --url https://jsonplaceholder.typicode.com \
  --body '{"id":1}'

Tip

Requests don't necessarily have to have a body, omitting it will not trigger the interactive mode and rather will create the request without body.

Generate a request in interactive mode

gouache generate

βš–οΈ License

See LICENSE.

🀝 Contributing

See CONTRIBUTING.md.

πŸ”’ Security

See SECURITY.md.

🫢 Code of conduct

See CODE_OF_CONDUCT.md.

About

Create HTTP requests from files and run them right from your terminal

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Languages