Req: Postman in the terminal
I use Postman a lot at work. It’s really helpful to have an interface where I can write down a request, run it, and then iterate on it based on the response. However, the fact that it’s a GUI tool puts some real limitations on it.
Between VS Code, zoom, docker, firefox, and slack, I’m often already pushing my computer a little harder than it’s happy place, and adding another electron application isn’t ideal. Worse than that, trying to eyeball my way through a 500 line JSON response is no fun at all.
I’d much rather have a CLI tool where I can pipe the results into jq and explore to my hearts content in a more focused way. For a while I tried just using curl
, but that had a different set of problems. Editing requests in Postman feels like iterating on code. I have a static document representing the request that can be saved between sessions, pull secrets from the environment (sort of), and have meaningful structure related to what I’m building. Iterating on a curl request just feels bad, especially when I need to send a request with a body.
I spent a while complaining to my coworkers that curl wouldn’t run HTTP requests from a file, and after I got all the whinging out of my system I realized that this should be a relatively easy thing to build. I wanted something that could
- run as a CLI application
- read requests in a standard format from a static file
- be distributed as a static binary (none of this install from npm nonsense)
So I wrote req. Req takes in a file containing a spec compliant HTTP request, performs that request, and returns the response body to stdout. By default it only returns the body, making it simple to pipe into other tools, but on a flag it can return other metadata as well.
I get that the world probably didn’t need another HTTP client, but it was fun to have a project to work in a language that I don’t get to work in every day that filled a real gap in the way I work. Often I struggle to stick with projects because the goal feels kind of abstract. It was very nice to have something that I am already using regularly to test and debug HTTP apps.