Skip to content

add headers to templated html response#92

Open
lalyos wants to merge 1 commit intodarklynx:masterfrom
lalyos:add-headers
Open

add headers to templated html response#92
lalyos wants to merge 1 commit intodarklynx:masterfrom
lalyos:add-headers

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