so://phie

verbal

A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal

blob: 975596b61292c9fc0fb7346cd165c96f88bb6a4a (971 bytes)[doc][blame][raw]

1#!/bin/bash

2

3declare -A config

4config=(

5 ["port"]=""

6 ["uri"]="/api"

7 ["method"]="GET"

8 ["args"]=""

9 ["token"]="test-token"

10)

11

12while read argument; do

13 key=$(echo "$argument" | awk '{split($0, a, "="); print a[1]}')

14 if [ -z "$key" ]; then

15 continue

16 fi

17 value=$(echo "$argument" | awk '{st = index($0, "="); print substr($0, st + 1)}')

18 config["$key"]=$value

19done <<< $(echo "$@" | tr " " "\n")

20

21# while read key; do

22# echo "$key: ${config[$key]}"

23# done <<< $(echo "${!config[@]}" | tr " " "\n")

24

25# echo ""

26

27url="http://localhost:${config["port"]}${config["uri"]}?${config["args"]}"

28

29echo ""

30echo "Request"

31echo "------------------------------------------------------------"

32

33echo "${config["method"]} $url"

34echo "verbal-token: ${config["token"]}"

35echo ""

36

37echo "Response"

38echo "------------------------------------------------------------"

39

40curl "$url" -I -g

41

42curl "$url" -s -g -X "${config["method"]}" -H "verbal-token: ${config["token"]}" | jq -r "."