mirror of
https://codeberg.org/vlw/curl.git
synced 2026-04-13 02:39:38 +02:00
docs: update README
This commit is contained in:
parent
f4ded08c4c
commit
3e1baff0c4
1 changed files with 47 additions and 26 deletions
73
README.md
73
README.md
|
|
@ -1,33 +1,58 @@
|
||||||
|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
# Simple curl bash wrapper
|
|
||||||
|
|
||||||
<img src="https://blob.vlw.se/01/0199056d-d6fc-748b-adbb-269c8c5237ab.png">
|
This is a wrapper for curl written in bash designed to be used along with Visual Studio Code.
|
||||||
|
|
||||||
---
|
> Mom, can we get Postman?
|
||||||
|
>
|
||||||
|
> We've got Postman at home!
|
||||||
|
>
|
||||||
|
> [\- Source](https://knowyourmeme.com/memes/we-have-food-at-home)
|
||||||
|
|
||||||
**This is a very simple wrapper for curl that I use with VSCode (code-server) to make HTTP requests - like Postman but super simple.**
|
[Here is a simpler version of this script that prints the response body directly to the console](/vlw/curl/src/tag/1.1.0)
|
||||||
|
|
||||||
VSCode is not required to run this script, I use it as a GUI.
|
# Get started
|
||||||
|
Clone this repo
|
||||||
|
```sh
|
||||||
|
git clone https://codeberg.org/vlw/curl --depth 1
|
||||||
|
```
|
||||||
|
|
||||||
|
This script uses separate files in the `curl/` directory for various request options. You can generate these files on first load by running the init script.
|
||||||
|
```sh
|
||||||
|
./init.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!Note]
|
||||||
|
> If you're using this with VSCode, drag each file into the workspace area where you want it to display. You of course don't have to follow the layout in the screenshot above.
|
||||||
|
|
||||||
# Files
|
# Files
|
||||||
This script uses separate files for various request options. Create these files in the same directory as `curl.sh`.
|
This script reads or writes values in these files to construct a request or show a response from a request.
|
||||||
|
|
||||||
## `params.txt`
|
## Disable SSL peer validation
|
||||||
URL search parameters. (Leading "?" is optional)
|
You can disable SSL peer validation (for self-signed certificates etc.) by creating an empty file `disable_peer_validation` in the base directory of this repo.
|
||||||
```
|
```sh
|
||||||
foo=bar&hello=world
|
touch disable_peer_validation
|
||||||
```
|
```
|
||||||
|
|
||||||
## `payload.json`
|
## Request
|
||||||
JSON request body that will be sent with all requests (except `GET`).
|
### `curl/req_params.txt`
|
||||||
|
URL search parameters. Each newline is treated as a separate search parameter.
|
||||||
|
```
|
||||||
|
foo=bar
|
||||||
|
fizz=buzz
|
||||||
|
```
|
||||||
|
|
||||||
|
### `curl/req_body.json`
|
||||||
|
JSON request body that will be sent with all requests (except `GET`). Leave empty to send nothing.
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"request_body_parameter": "request_body_value"
|
"request_body_parameter": "request_body_value"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## `headers.json`
|
### `curl/req_headers.json`
|
||||||
Key-value JSON object of optional request headers.
|
Key-value JSON object of optional request headers.
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
|
@ -35,8 +60,15 @@ Key-value JSON object of optional request headers.
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## `disable_peer_validation`
|
## Response
|
||||||
Optional empty file that when present will disable SSL peer validation - for self-signed certificates etc.
|
### `curl/resp_headers.txt`
|
||||||
|
A raw output of the response headers from the last request
|
||||||
|
|
||||||
|
### `curl/resp_body.txt`
|
||||||
|
The raw response body received from the last request
|
||||||
|
|
||||||
|
### `curl/resp_body.json`
|
||||||
|
The raw response body parsed into- and automatically pretty-printed JSON
|
||||||
|
|
||||||
# Make a request
|
# Make a request
|
||||||
Run the `curl.sh` file from your shell and pass it two parametes for URL and request method.
|
Run the `curl.sh` file from your shell and pass it two parametes for URL and request method.
|
||||||
|
|
@ -44,14 +76,3 @@ Run the `curl.sh` file from your shell and pass it two parametes for URL and req
|
||||||
```sh
|
```sh
|
||||||
./curl.sh https://example.com GET
|
./curl.sh https://example.com GET
|
||||||
```
|
```
|
||||||
|
|
||||||
The response body will be printed to stdout.
|
|
||||||
|
|
||||||
*Example*
|
|
||||||
```
|
|
||||||
vlw@example:/curl$ ./curl.sh https://example.com GET
|
|
||||||
GET https://example.com?foo=bar
|
|
||||||
|
|
||||||
"This is an example response body in plaintext"
|
|
||||||
vlw@example:/curl$
|
|
||||||
```
|
|
||||||
Loading…
Add table
Reference in a new issue