can we use RouteRuless for the response object?

Not applicable

Hi, can we use RouteRules for the response object in proxy endpoint xml(default.xml)?

Example:

<RouteRule name="test"> <Condition>(response.status.code == 503) and (environment.name == "test")</Condition> <TargetEndpoint>us-temp-test</TargetEndpoint> </RouteRule>

Thanks in advance.

0 5 188
5 REPLIES 5

Could you explain further what you are attempting to do? I'm not clear on what a route rule would do for you after the response has been returned from the target.

Dear @Swapna ,

As commented by @Carlos Eberhardt , Can you please clarify what exactly you are trying to solve ? Above question is little confusing because route rules are always used in Request context in Apigee Edge.

Let me explain why Route Rules are used in Apigee & What problems does it solve below,

  • A route determines the path of a request from the ProxyEndpoint to the TargetEndpoint.
  • Route rule is used to determine target end point to which request will be sent if multiple target endpoints are configured.
  • For example, Let's say i have CRM system & HRM system . My user data is stored in both places with little variation
    • Let's say i would like to expose proxy endpoint GET - /user
    • GET - /user?target=crm should route request to CRM system endpoint http://crm.com/user
    • GET - /user?target=hrm should route request to HRM system endpoint http://hrm.com/user
    • Remember, Proxy EndPoint is single one which is GET /user & we will use route rules to route request to different targets using query param as condition in routerules.
  • So, RouteRules are always used in Request Context
  • Once response is returned from target server, there is no need to do routing because you have only one thing i.e client which made API call to which response will be returned.
  • You can find more about route rules in Apigee Edge here.
  • So, Ideally, RouteRules in response doesn't make any sense in Apigee Edge Context.

What I understand is , You would like to hit some other target server when response fails from your main target server so that you can still serve client request. Just like a backup target server.

Keep us posted if you meant something else / Usecase you are trying to solve.

@Carlos Eberhardt and @Anil Sagar. Thanks for responding. I know we can use the RoutesRules for the request object. Just curious to know, is there any other way that we can route traffic to another URL or location other than using FaultRules for response object? Thanks!

@Swapna , I am afraid , there is no other way than using service callouts & step conditions / fault rules. If you come across any, feel free to share in community.

Former Community Member
Not applicable

@Swapna if the requirement is to invoke something vs routing (something completely different) as @Anil Sagar suggests you can use service callouts. If you are trying to implement a fire & forget pattern, you can do that via a JavaScript policy. See an example of that here. Hope this helps.