Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add headers to templated html response #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lalyos
Copy link

@lalyos lalyos commented Dec 3, 2023

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

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


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant