Skip to content

Add headers rendering and example of basicauth#74

Merged
zhouzhuojie merged 2 commits intomasterfrom
zz/add-base64-env-example
Apr 28, 2020
Merged

Add headers rendering and example of basicauth#74
zhouzhuojie merged 2 commits intomasterfrom
zz/add-base64-env-example

Conversation

@zhouzhuojie
Copy link
Contributor

Previously the headers in reply_http and send_http are not rendered with the context, this PR adds that so that headers can also be dynamic.

Example:

- key: base64-basicauth-with-env
  kind: Behavior
  expect:
    http:
      method: POST
      path: /base64-basicauth-with-env
  actions:
    - reply_http:
        headers:
          Authorization: '{{ printf "foobar:%s" (env "BASIC_AUTH_PASS") | b64enc }}'
        status_code: 200


a.Headers, err = renderHeaders(ctx, a.Headers)
if err != nil {
return err
Copy link
Contributor

@michelleheh michelleheh Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the same logrus to be consistent with the render of body failure?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I see that it's happening in renderHeaders.

Copy link
Contributor

@michelleheh michelleheh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! 👍Will you consider adding a unit test? Also, it will be great to add some information to the README.


a.Headers, err = renderHeaders(ctx, a.Headers)
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I see that it's happening in renderHeaders.

@zhouzhuojie zhouzhuojie merged commit 19f7275 into master Apr 28, 2020
@zhouzhuojie zhouzhuojie deleted the zz/add-base64-env-example branch April 28, 2020 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants