so://phie

verbal

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

blob: 14dd20cde53fc2b27621e7954c74ba734a8f739c (965 bytes)[doc][blame][raw]

1#!/bin/bash

2

3declare -A config

4config=(

5 ["port"]=4200

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 "Request"

30echo "------------------------------------------------------------"

31

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

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

34echo ""

35

36echo "Response"

37echo "------------------------------------------------------------"

38

39curl "$url" -I -g

40

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