Add support for API key in upload-jmespath script
This commit is contained in:
@@ -4,6 +4,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
API_URL="https://jmespath-playground.koszewscy.waw.pl"
|
API_URL="https://jmespath-playground.koszewscy.waw.pl"
|
||||||
JSON_FILE="-"
|
JSON_FILE="-"
|
||||||
|
ADD_HEADERS=()
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo "Usage: $0 [--api-url <url>] [--json-file <file>]"
|
echo "Usage: $0 [--api-url <url>] [--json-file <file>]"
|
||||||
@@ -16,6 +17,10 @@ while [[ $# -gt 0 ]]; do
|
|||||||
API_URL="$2"
|
API_URL="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
--api-key)
|
||||||
|
ADD_HEADERS+=("-H" "X-API-Key: $2")
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
--json-file)
|
--json-file)
|
||||||
JSON_FILE="$2"
|
JSON_FILE="$2"
|
||||||
shift 2
|
shift 2
|
||||||
@@ -36,6 +41,7 @@ done
|
|||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Accept: application/json" \
|
-H "Accept: application/json" \
|
||||||
|
"${ADD_HEADERS[@]}" \
|
||||||
--data @${JSON_FILE} \
|
--data @${JSON_FILE} \
|
||||||
"$API_URL/api/v1/upload"
|
"$API_URL/api/v1/upload"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user