darklynx / request-baskets

HTTP requests collector to test webhooks, notifications, REST clients and more ...
https://rbaskets.in
MIT License
351 stars 51 forks source link

add headers to templated html response #92

Open lalyos opened 11 months ago

lalyos commented 11 months ago

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:

$ 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: fake@ema.il" ${URL}/${BASKET}

user: [fake]
email: [fake@ema.il]