request-baskets icon indicating copy to clipboard operation
request-baskets copied to clipboard

add headers to templated html response

Open lalyos opened this issue 2 years ago • 0 comments

With this change not only query params but the headers are also available in templated html response.

There are at least 2 use cases which would be covered:

  • could be used as an upstream for oauth2-proxy
  • could be used for various webhooks, which expect a json response with some header/query values
$ BASKET=getuser
$ URL=https://rbaskets.in

$ T=$(curl -s ${URL}/api/baskets/${BASKET} -d '' | jq .token -r )

$ curl -X PUT -H "Authorization: $T" ${URL}/api/baskets/${BASKET}/responses/GET \
  -d '{"status":200,"headers":{},"body":"user: {{ index .headers \"X-Forwarded-Preferred-Username\" }}\nemail: {{ index .headers \"X-Forwarded-Email\" }}","is_template":true}'


## test
$ curl -H "X-Forwarded-Preferred-Username: fake" -H "X-Forwarded-Email: [email protected]" ${URL}/${BASKET}

user: [fake]
email: [[email protected]]


lalyos avatar Dec 03 '23 21:12 lalyos