How to access headers added using AssignMessage policy in Microgateway custom plugin

I have a proxy created with Assign Message policy in the pre-flow which adds a header with it's value. I am trying to build a Microgateway custom plugin which needs to access this request header of that proxy.

I have tried printing the request.headers of the onrequest event handler but it does not reflect the newly added headers. Although these headers are visible in the trace response

My ultimate aim is to read a variable assigned from a previous KVM policy and pass that variable to custom plugin.

Please let me know how this can be achieved or a better way to implement such solution.

Solved Solved
1 4 946
1 ACCEPTED SOLUTION

Thanks for the clarification on the assign message policy usage in the microgateway and sorry for the delay in response, I got sidetracked a little bit.

We were looking to dynamically lookup an endpoint for the target endpoint in the proxies deployed on microgateway. The endpoints are environment specific so when we promote the proxy to the higher regions we are looking up a KVM defined on Edge and retrieve the environment specific target endpoints.

Figured out there is a plugin documented at : https://github.com/srinandan/router where srinandan explains how in the microgateway this can be achieved with the lack of TargetSerer that is available on Apigee Edge proxy implementation.

The above plugin was added to the microgateway instance and we are now able to use the same proxy in all regions.

We were trying to achieve the same using assign message policy to add a header to contain the kvm endpoint and use it in a javascript/custom plugin to set the target endpoint and were unable to read the added header in the plugin.

appreciate your help on this issue.

View solution in original post

4 REPLIES 4

Not clear. Maybe I am confused, or maybe you are operating under a mis-conception.

First , let's understand.

  • AssignMessage is used in API Proxies that run in the Apigee Edge message processor.
  • Microgateway is an alternative to the MessageProcessor.
  • If you are using Microgateway then you are not using AssignMessage.

You are using the term "Custom plugin" which I think implies "micro gateway". But microgateway will not read from KVM and will not use AssignMessage.

There is sometimes confusion because the Microgateway does query the Apigee Edge configuration for a list of proxies. But any configuration you place in those proxies is ignored by the Microgateway. Any. policies on those proxies are never used.

Are you all clear on that?

if you had assumed these things worked together, then.... now you know. You'll need to re-think the solution.

If you have been clear on the separation, then please explain your situation in a different way:

  1. what you want to accomplish (I think just header injection = adding a header. If so, then I'm clear)
  2. what you have tried. Show the AssignMessage policy and show where you have attached it. Also show how you are invoking the API Proxy.
  3. What results you see. It seems you can see the headers in the response, but... ??? Where are you NOT seeing the headers?

and also please also clarify what you mean by custom plugin, in the context of a regular (normal) API Proxy in Apigee Edge.

Mirza, any response?

Thanks for the clarification on the assign message policy usage in the microgateway and sorry for the delay in response, I got sidetracked a little bit.

We were looking to dynamically lookup an endpoint for the target endpoint in the proxies deployed on microgateway. The endpoints are environment specific so when we promote the proxy to the higher regions we are looking up a KVM defined on Edge and retrieve the environment specific target endpoints.

Figured out there is a plugin documented at : https://github.com/srinandan/router where srinandan explains how in the microgateway this can be achieved with the lack of TargetSerer that is available on Apigee Edge proxy implementation.

The above plugin was added to the microgateway instance and we are now able to use the same proxy in all regions.

We were trying to achieve the same using assign message policy to add a header to contain the kvm endpoint and use it in a javascript/custom plugin to set the target endpoint and were unable to read the added header in the plugin.

appreciate your help on this issue.

Great! Thank you Mizra for the reply and the insight.