#!/bin/bash -x

TRAEFIK="http://traefik.docker.localhost"
DOMAIN="docker.localhost"
SERVICES=$(curl ${TRAEFIK}/api/http/routers |jq ".[].rule" |grep "${DOMAIN}" |awk -F\` '{print $2}')
SELECTION=$(echo -e "$SERVICES" | uniq -u | rofi -dmenu -p "Select traefik service: "  -theme /usr/share/rofi-menus-git/themes/appsmenu.rasi)
[ ! -z "$SELECTION" ] && xdg-open "http://${SELECTION}"
