Tutorial Intro
Let's discover httpx in less than 5 minutes.
Getting Started
Please install httpx from https://github.com/httpx-sh/httpx/releases
If you are Mac user, please use brew install httpx-sh/tap/httpx to install httpx.
Create index.http file
Create a simple index.http file with following code:
#!/usr/bin/env httpx --httpfile
### get my internet ip
# @name myip
GET https://httpbin.org/ip
Then you can input httpx myip to invoke http request. Or you can input chmod u+x index.http then execute ./index.http myip
How httpx to find http file?
- http file assigned by
-for--httpfileoption - httpx will look
index.httpby default if no http file assigned - If httpx can not find
index.httpin current directory, and it will lookindex.httpin parent directory until root directory. - If index.http not found in parent directory chain, and it will try to find
~/.servicex/index.httpas default index.http
Environment variables overwrite?
httpx supports to load environment variables from http-client.env.json and http-client.private.env.json, and compatible with JetBrains HTTP Client plugin.
For some cases, you want to overwrite environment variables from command line, and you can use --name=value option.
For example, you have a http request:
### fetch user detail
//@name user
GET https://api.example.com/user/{{id}}
you can use httpx user --id=111 to overwrite id value from http-client.env.json.
Attentions:
- Space style:
--id xxxnot allowed, and you should use--id=xxx - Reserved variables:
list, data, summary, and they are option names for httpx CLI
HTTP file syntax
Please refer https://www.jetbrains.com/help/idea/exploring-http-syntax.html