Http CLI focused on UX and git-heavy workflow
Making requests from CLI can be very intimidating. I myself have tried some tools, and I always ended up falling back to Insomnia.
Lapse's design is built on top of files that will define the whole behavior. Not only this simplifies the whole proccess of using it, but it also lets you use your favorite VCS.
- Http requests
- Multipart/form requests
- Environments and variables
- Secrets
- Lua scripts and interpolation
├── .lapse
├── env
│ └── default
│ ├── hooks.json
│ ├── secrets.json
│ └── variables.json
├── requests
│ └── httpbin.md
└── scripts
└── test.lua
I recommend to ignore these entries in your VCS:
.lapse/log/*
.lapse/state/*
secrets.jsonThis is how a request file looks like
POST httpbin.org/post
Content-Type: application/json
{
"name": "${env.name}"
}
---
# Request documentation
Here is some valid markdown
Now, there is a lot to unpack here.
The first two lines are self explanatory. Any line that comes directly after the request is treated like a header, so it has to follow this key:value syntax
After the blank like, we have our body. There is nothing special about the request body, it is just sent as raw text. The tool doesn't detect when you are sending json, so you are supposed to add the Content-Type header by yourself.
After the body, we can see a triple dash separating the request from the document. This second section is just raw text that you can use to add informations about your request. This second part is optional, so you can omit the triple dash and not include it at all.
Also, we do have this interpolated value (${env.name}), this is an env variable
These request files can be organized however you want, as long as they are inside of the requests/ folder, you will be able to call them from their unique path.
Env variable files are just json files with values. Any json valid value is accepted, even objects. You are not supposed to throw secrets into environments, we will get there yet.
{
"name": "John"
}Same goes for secrets.
This is what a hooks file looks like
{
"pre-request": {
"enabled": true,
"scripts": ["pre.lua"]
},
"post-request": {
"enabled": false,
"scripts": ["post.lua"]
}
}The keys are the event names. The scripts path is relative to the scripts folder, and the scripts are executed in the order they are passed to the array.
Scripts are just lua scripts. We will have more details about its API later.
Secrets are just like env variables, but they are not supposed to be tracked by VCS
{
"password": "shhhh"
}Initializes Lapse space at current dir, setting up some files and directories as well.
lapse initLists all requests.
lapse lsSends a request. The query argument will be used to fuzzy search for the request. Should the search match more than one request, the user will be prompted a selector, which is also the behavior for when the query argument is omited.
lapse send [query]The way it searches, it uses the request path as a string to query. So if we have something like:
├── .lapse
├── env
│ └── default.json
├── requests
│ ├── httpbin.md
│ └── httpbin
│ └── get.md
The searchable entries would be:
"httpbin"
"httpbin/get"
So, a query like "hg" would match the second entry.
Runs a script.
lapse run [query]You can also use script run:
lapse script run [query]Lists all scripts.
lapse script lsOutputs the completion script to a given shell.
lapse completion <shell>Lists all environments.
lapse env lsSwitches to an enviromnent.
lapse env switch [query]Logs the response logs for a given request
lapse log [query]If your env looks like this:
{
"name": "John"
}You can access values like this:
POST https://names.com/${env.name}
If your secrets.json file looks like this
{
"password": "Shhhh"
}You can access values like this:
POST https://auth.com/${secret.password}
Sends a request, and returns a table that represents a response log.
local result = lapse:request("httpbin/get")
print(result.status)
print(result.text)
print(result.request)
for k, v in pairs(result.headers) do
print(k, v)
endThis project is licensed under the GNU General Public License version 3 or later (GPL-3.0-or-later).
See LICENSE for the full license text.