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

New Feature - Add custom HTTP Header #313

Closed
2 tasks done
FelixBoers opened this issue Apr 13, 2018 · 4 comments
Closed
2 tasks done

New Feature - Add custom HTTP Header #313

FelixBoers opened this issue Apr 13, 2018 · 4 comments

Comments

@FelixBoers
Copy link
Contributor

FelixBoers commented Apr 13, 2018

It should be possible to configure custom HTTP header with static values (without transformation!) for both the downstream response and the upstream request. Currently it's only possible to set them for the downstream response (see #280).

Sample configuration:

{
  "ReRoutes": [
    {
      "DownstreamHeaderTransform": {
        "X-Custom-Header": "Value put into response to downstreams"
      },
      "UpstreamHeaderTransform": {
        "X-Custom-Header": "Value put into request for upstream"
      },
    }
  ]
}

If the header is sent in the origin request then it gets overwritten.

Related to #280

Checklist

  • Write some tests
  • Edit documentation
@FelixBoers
Copy link
Contributor Author

I've started implementing this and will create a pull request soon.

@TomPallister
Copy link
Member

@FelixBoers thank you so much for this contribution! Really nice to get some help 😄

Will close the issue now I merged the PR!

@SimantoR
Copy link

I'm wondering if this is possible programmatically? I need to be able to pass user id and I was thinking maybe I could plug it somewhere within Ocelot's pipeline to add name from Principle to the header before passing it downstream.

@FelixBoers
Copy link
Contributor Author

FelixBoers commented Dec 18, 2018

@SimantoR I'm not exactly sure if I understand you right but I think this will get you there: https://ocelot.readthedocs.io/en/latest/features/delegatinghandlers.html

So I would suggest to write a DelegatingHandler which manipulates the downstream request and then calls the base handler.

As far as I know there is no direct way for achieving this functionality.

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

No branches or pull requests

3 participants