Change custom request & response commands by two kapow subcommands

This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-09-05 07:55:55 +02:00
parent ec20e02534
commit 6c65064e12
10 changed files with 65 additions and 97 deletions
+7 -7
View File
@@ -17,8 +17,8 @@
#
kapow route add / - <<-'EOF'
response /headers/Content-Type text/html
response /body <<-HTML
kapow set /response/headers/Content-Type text/html
kapow set /response/body <<-HTML
<html>
<body>
<a href='javascript: Array.from(document.querySelectorAll("a")).filter(x => x.href.indexOf("magnet") != -1 ).map(x => x.href = "http://localhost:8080/save/magnet?link="+encodeURI(x.href))'>Add me to your bookmarks!</a>
@@ -28,16 +28,16 @@ kapow route add / - <<-'EOF'
EOF
kapow route add /save/magnet -e '/bin/bash -c' - <<-'EOF'
link=$(request /params/link)
[ -z $link ] && response /status 400 && exit 0
link=$(kapow get /request/params/link)
[ -z $link ] && kapow set /response/status 400 && exit 0
watch_folder=/tmp
cd $watch_folder
[[ "$link" =~ xt=urn:btih:([^&/]+) ]] || exit;
echo "d10:magnet-uri${#link}:${link}e" > "meta-${BASH_REMATCH[1]}.torrent"
response /status 302
response /headers/Location /torrent/list
kapow set /response/status 302
kapow set /response/headers/Location /torrent/list
EOF
kapow route add /torrent/list -c 'response /body "Not Implemented Yet"'
kapow route add /torrent/list -c 'kapow set /response/body "Not Implemented Yet"'