Layer7 API Management

 View Only
  • 1.  Overloading API URL

    Posted Nov 12, 2019 01:29 PM
    It is a common practice to add id in the url as findOne instead of findAll

    e.g.

    {{machine}}:8081/api/customers means to findAll customers
    {{machine}}:8081/api/customers/2 means to find one with id = 2

    For using the "HTTP(S) Routing" policy, we can only provide one URL and it seems CA Gateway not passing on the id at all ?

    /api/customers/2 always route as 8081/api/customers/ ?


    Any way to configure parameter in the route policy?

    Thanks in advance for any tip.
    Louie











    ------------------------------
    Louie
    ------------------------------


  • 2.  RE: Overloading API URL

    Broadcom Employee
    Posted Nov 12, 2019 04:57 PM
    Hi Louie,

    Can you clarify the request? Are you routing to an external server or another endpoint on the Gateway?
    The route assertion should have no issues in routing to /api/customers/2 vs /api/customers and differentiating between the two, especially externally.

    I can see some potential issues if this is routing to another Gateway endpoint, but it would depend on how you have defined the resolution path.
    If you can provide a little more detail I will be happy to assist further, Thank you.

    Regards,
    Joe


  • 3.  RE: Overloading API URL
    Best Answer

    Broadcom Employee
    Posted Nov 12, 2019 08:18 PM
    Dear Louie,
    Usually you can do it like this,
    1. you publish the gateway service with resolution path similar like this, 
    /customer*
    it allows you to call the gateway with different uri, for example,
    http(s)://<gateway>:<port>/customer
    http(s)://<gateway>:<port>/customer/2

    2. you parse the uri in your policy 
    use split variable assertion or regex assertion to pick up the customer id from ${request.http.uri}, and set the value to a context variable, for example ${customerid}

    3. then in the route assertion, you can set the url as,
    http://machine:8081/api/customer/${customerid}

    Regards,
    Mark


  • 4.  RE: Overloading API URL

    Posted Nov 13, 2019 11:35 AM
    Thanks for the tips, I am planning to simply do http://${webAppHost}/${request.url.path}.


    ------------------------------
    Enterprise Architect
    TwoCoins.ca Inc.
    ------------------------------