Layer7 API Management

  • 1.  How can I make a variable available from message received to an other policy ?

    Posted Dec 12, 2018 09:59 AM

    Hello.

    In "message received", if a request matches some condition I need to set a variable say : env=test. In some other case I could set it to say env=stage. So in a further down policy I can route to say http://${env}AppHostSuffix.domain.com/... Is this possible ?I used "Export Variables from Fragment"  but it makes the variable available to *parent* policy not to *other* policies. But it fails : My Route url is set to "http://AppHostSuffix.domain.com/..." and fail.

     

    Should I use and modify a Cluster Wide variable ? But then, if I modify it (btw possible at all with an assertion ?), wouldn't it be modified for *all* request coming next ? That woul not be what I want.

     

    The overall picture : Abstracting policies so they become environment agnostic so they can be propagated from env to env with  GMU.

    Regards.

    Gilles



  • 2.  Re: How can I make a variable available from message received to an other policy ?
    Best Answer

    Broadcom Employee
    Posted Dec 12, 2018 12:25 PM

    Hello,

     

    When you are using the variable in the policy are you referencing it as ${Request.shared.env}?

     

    I am unsure what you mean by the parent and other policies. The message received would be executed when the message is received, but before the service is resolved. 

     

    I've set env = test in my message received policy. Then created a new service /testService. In this service I use a simple return template response to display ${request.shared.env} and get the desired result.

     

    Regards,

    Joe



  • 3.  Re: How can I make a variable available from message received to an other policy ?

    Posted Dec 13, 2018 12:20 PM

    Spot on. I didn't know nor found in the doc the "request.shared." prefix. It does work perfectly. Thanks.