curlenv set of conventions for managing prepared HTTP requests via curl. Environments are just collections of shell environment variables that are managed by direnv.
It aims to be a simple command-line alternative to Postman that directly leverages well known tools.
Important
It's recommended you use curl v8.7.0 or greater. curl v8.7.0 fixed a bug (curl/curl@0f0edc2) where curl would not fail when it encountered a missing environment variable.
This a template repository and meant to be cloned as a starting point for your own project. In GitHub you can click the
Use this template
button at the top of this page to get started.
Files within env, data, request, and workflow directories are only examples and can be deleted to be replaced by our own. They exist as a starting point for your own work.
Name | Description |
---|---|
env/ | *.env and *.envrc files for direnv. |
data/ | Static and templated data files. |
request/ | Requests defined by curl configuration files. |
workflow/ | Compositions using data and request files. |
.envrc | Entrypoint file for direnv. |
required-variables.txt | List of environment variables that are considered required for the project. All environments must set these variables. |
.envrc.local | Uncommitted, local run commands sourced by .envrc |
.envrc.curlenv.* | Files generated by bin/curlenv-switch using *.env and *.envrc files in env/. These files are loaded by .envrc by direnv. |
Environments are managed by direnv and loaded with the bin/curlenv-switch
command.
Both *.env
and *.envrc
environment files are supported. If all you need is a static environment variables then choose
the *.env
variant, because *.envrc
files sourced by .envrc
aren't guarded by direnv
's security framework.
Refer to the direnv documentation for .env
and .envrc
syntax and stdlib
functions.
You can load environments via the bin/curlenv-switch
script. The command accepts a single argument for the environment name. References to both the primary environment files (<name>.env
and <name>.envrc
) and optional secrets files (<name>.secret.env
and <name>.secret.envrc
) are symlinked in the project root.
; curlenv-switch example
curlenv-switch: wrote /Users/brett/Code/curlenv/.env.curlenv
curlenv-switch: wrote /Users/brett/Code/curlenv/.env.curlenv.target
direnv: loading ~/Code/curlenv/.envrc
direnv: loading ~/Code/curlenv/.envrc.curlenv.target
direnv: export +CURLENV_CURRENT +EXAMPLE_HEADER +EXAMPLE_HOSTPORT +EXAMPLE_SCHEME +EXAMPLE_USER -PS2 ~PATH
When a target environment is loaded, environment variable names (one per line) from required-variables.txt
are applied to a
env_vars_required
directive.