Software /
code /
prosody-modules
Diff
mod_rest/example/rest.sh @ 5856:75dee6127829 draft
Merge upstream
author | Trần H. Trung <xmpp:trần.h.trung@trung.fun> |
---|---|
date | Tue, 06 Feb 2024 18:32:01 +0700 |
parent | 5689:e5ad3f1f48bd |
line wrap: on
line diff
--- a/mod_rest/example/rest.sh Tue Aug 29 23:51:17 2023 +0700 +++ b/mod_rest/example/rest.sh Tue Feb 06 18:32:01 2024 +0700 @@ -13,6 +13,8 @@ HOST="" DOMAIN="" +SESSION="session-read-only" + if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" ]; then # Config file can contain the above settings source "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" @@ -23,7 +25,7 @@ fi if [[ $# == 0 ]]; then - echo "${0##*/} [-h HOST] [/path] kind=(message|presence|iq) ...." + echo "${0##*/} [-h HOST] [-rw] [/path] kind=(message|presence|iq) ...." # Last arguments are handed to HTTPie, so refer to its docs for further details exit 0 fi @@ -35,6 +37,12 @@ HOST="$(hostname)" fi +if [[ "$1" == "-rw" ]]; then + # To e.g. save Accept headers to the session + SESSION="session" + shift 1 +fi + if [[ "$HOST" != *.* ]]; then # Assumes subdomain of your DOMAIN if [ -z "${DOMAIN:-}" ]; then @@ -55,4 +63,4 @@ shift 1 fi -https --check-status -p b --session rest -A oauth2 -a "$HOST" --oauth2-scope "$SCOPE" "$HOST/rest$GET_PATH" "$@" +https --check-status -p b --"$SESSION" rest -A oauth2 -a "$HOST" --oauth2-scope "$SCOPE" "$HOST/rest$GET_PATH" "$@"