-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Customize the shell script a bit more
Add a shbang using env Let override directly the url on argument if set Still handle -l and GOSMEE_DEBUG_SERVICE
- Loading branch information
Showing
1 changed file
with
14 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
#!/bin/bash | ||
# | ||
#!/usr/bin/env bash | ||
# Copyright 2023 Chmouel Boudjnah <[email protected]> | ||
# Replay script with headers and JSON payload to the target controller. | ||
# | ||
# You can switch the targetURL to another one with the -l switch, which defaults | ||
# to http://localhost:8080. | ||
# You can switch the targetURL with the first command line argument and you can | ||
# the -l switch, which defaults to http://localhost:8080. | ||
# Same goes for the variable GOSMEE_DEBUG_SERVICE. | ||
# | ||
# You can customze this target with the env variable: GOSMEE_DEBUG_SERVICE | ||
set -euxf | ||
set -euxfo pipefail | ||
cd $(dirname $(readlink -f $0)) | ||
|
||
targetURL="{{ .TargetURL }}" | ||
[[ ${1:-""} == -l ]] && targetURL=${GOSMEE_DEBUG_SERVICE:-"http://localhost:8080"} | ||
if [[ ${1:-""} == -l ]]; then | ||
targetURL="http://localhost:8080" | ||
elif [[ -n ${1:-""} ]]; then | ||
targetURL=${1} | ||
elif [[ -n ${GOSMEE_DEBUG_SERVICE:-""} ]]; then | ||
targetURL=${GOSMEE_DEBUG_SERVICE} | ||
fi | ||
|
||
curl -sSi -H "Content-Type: {{ .ContentType }}" {{ .Headers }} -X POST -d @./{{ .FileBase }}.json ${targetURL} |