#!/bin/bash
printf '%s\n\n' 'Content-Type: text/html';
source ../src/exprash.sh;
declare -A cats;
cats[calico]="Calico";
cats[sphynx]="Sphynx";
cats[ragdoll]="Ragdoll";
cats[scottish_fold]="Scottish Fold";
get '/' && {
printf '
Cats
\n';
printf '\n';
for key in "${!cats[@]}"; do
printf '- %s
\n' "$key" "${cats[$key]}";
done
printf '
\n';
}
get '/cats/:cat' && {
key=$(param 'cat');
if [[ -v "cats[$key]" ]]; then
printf 'Your Cat: %s
\n' "${cats[$key]}";
else
next;
fi;
}
all '/cats/:cat' && {
printf 'Error: Cannot find that cat
\n';
}