feat: default method to GET if not provided (#9)

Set the default request method to `GET` if no method is provided

Reviewed-on: https://codeberg.org/vlw/curl/pulls/9
This commit is contained in:
Victor Westerlund 2026-04-06 10:25:07 +02:00
parent a42be0792c
commit 328cebc703

View file

@ -1,8 +1,8 @@
#!/bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <url> <request_method>"
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <url> [request_method]"
exit 1
fi
@ -17,7 +17,7 @@ RESP_BODY_RAW_FILE="curl/resp_body.txt"
RESP_BODY_JSON_FILE="curl/resp_body.json"
url="$1"
method="$2"
method="${2:-GET}"
# Append url search parameters
if [ -f $REQ_PARAMS_FILE ]; then