Multiple endpoints for different Operations

I am creating a proxy where the target server is same for all the requests.

The only difference is call type (GET, DELETE, POST,PUT) with different targetBasePath 

Below are few target endpoints. if you see all are hitting same server(https://dev.backend.portal.abc.com/) but the targetBasePath is different.

GET
https://dev.backend.portal.abc.com/option/name
https://dev.backend.portal.abc.com/user
https://dev.backend.portal.abc.com/support/user/{userID}

POST
https://dev.backend.portal.abc.com/user

DELETE
https://dev.backend.portal.abc.com/user/id/{userID}

PUT
https://dev.backend.portal.abc.com/user/name/{username}

can you suggest a design where I can have an option to create only or minimum proxies. For now there are 40 such API endpoints and I do not want to create 40 proxies for each of these endpoints.

 

 

0 1 65
1 REPLY 1

An Apigee proxy acts as a "pass through" unless you configure it to do something different.

What I mean is, if the Apigee proxy receives a GET /foo/bar , it will invoke GET /foo/bar on the target upstream. Your target may supply a basepath so the effective URL for the target may be something like https://dev.upstream.com/something/foo/bar . But ... in any case Apigee acts as a pass-through.

A POST or PUT or DELETE will also result in a similar pattern. The same verb gets propagated to the outbound request. The path works the same way.

I am not clear on what you want the Apigee proxy to do. You showed verb and URLs for the target (outbound, upstream) invocation. But you did not show the same information for the inbound request. So I am not sure what you want to do.

Some common things people do:

  • configure Apigee to "filter" inbound requests so as to propagate only known/valid requests to the upstream. In that case you can specify a set of Conditional Flows in your ProxyEndpoint, which match on the pairs of (request.verb, proxy.pathsuffix) that you consider to be valid. The conditional flows don't need to do anything, except check the path/verb combination. Then use a Conditional flow with no Condition to reject all other requests. For example. This proxyendpoint will reject all requests that are neither GET /t1 nor POST /t2 :

    <ProxyEndpoint name="endpoint1">
    
      <HTTPProxyConnection>
        <BasePath>/your-base-path</BasePath>
        <VirtualHost>secure</VirtualHost>
      </HTTPProxyConnection>
    
      ...
      <Flows>
        <Flow name='t1'>
          <Condition>proxy.pathsuffix MatchesPath "/t1" and request.verb = "GET"</Condition>
        </Flow>
    
        <Flow name='t2'>
          <Condition>proxy.pathsuffix MatchesPath "/t2" and request.verb = "POST"</Condition>
        </Flow>
    
        <Flow name='unknown request'>
          <Request>
            <Step><Name>RF-Unknown-Request</Name></Step>
          </Request>
        </Flow>
    
      </Flows>
    
      <RouteRule name="default">
        <TargetEndpoint>target-1</TargetEndpoint>
      </RouteRule>
    
  • Configure Apigee to route requests with particular verb/path combinations to different backend targets. You can do that with RouteRules. It sounds like this is not what you want. I won't give an example here.

  • Configure Apigee to modify paths sent to the backend, depending on the verb/path received on input. Maybe this is what you want? You can do this by setting the target.url variable, in the TargetEndpoint. (Search the community for plenty of examples of this)

If there's something else, maybe you can elaborate on the problem you're trying to solve.