mirror of
https://git.mills.io/prologic/zs-starter-template.git
synced 2024-11-22 05:16:04 +03:00
18 lines
448 B
Plaintext
18 lines
448 B
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
# Set content-type to text/plain
|
||
|
echo "Content-type: text/plain"
|
||
|
echo ""
|
||
|
|
||
|
# read JSON from request body (stdin) and store in a tempoary file (fd)
|
||
|
tmpfile="$(mktemp /tmp/req.XXXXXX)"
|
||
|
trap 'rm -f -- "$tmpfile"' INT TERM HUP EXIT
|
||
|
cat >"$tmpfile"
|
||
|
|
||
|
# Extract fname and lname fields from JSON
|
||
|
firstName="$(jq -r '.fname' <"$tmpfile")"
|
||
|
lastName="$(jq -r '.lname' <"$tmpfile")"
|
||
|
|
||
|
# Send a response
|
||
|
printf "Hello %s %s !" "$firstName" "$lastName"
|