AnsweredAssumed Answered

General best API design approach validation required

Question asked by Kareem.shaik7 on Jan 24, 2017
Latest reply on Feb 2, 2017 by Kareem.shaik7

Hi

 

Can someone help me to validate our API designs? Because one of our colleague has raised concern on our design and would like to hear if we are going in a right path. 

 

I would describe two approaches here, one which we are implementing and the other one suggested by my colleague. 

 

As I am not sure what to call these patterns in API design terminology, I gave some names to them for our reference

 

Composition Pattern:

Currently we are following this pattern. 

1 - One Policy

2 - Supports multiple Http Methods

3 - Base URI*

 

Example:

Policy: Create, Update and Get Employee Profile

Base URI   : /company/v1/employees/profile*

HTTP Methods Support: POST/PUT/GET

 

All below scenarios are supported in single policy and routed to backend service

1. /company/v1/employees/profile   POST

2. /company/v1/employees/profile   PUT

3. /company/v1/employees/profile/{SOURCEID}/{ID} GET

4. /company/v1/employees/profile/{SOURCEID}/{EMAIL} GET

 

Backed system supports the same URIs. No much logic involved in routing.

 

 

Parent - Child Policy Pattern (Suggested By my colleague)

Parent Policy with similar configuration specified in Composition Layer. 

- Instead of routing to backend service from directly from Parent API route it via child policy. 

- It means, create a individual policy for each scenarios as listed below

1. /company/v1/employees/profile/create   POST

2. /company/v1/employees/profile/update   PUT

3. /company/v1/employees/profile/get/{SOURCEID}/{ID} GET

4. /company/v1/employees/profile/get/{SOURCEID}/{EMAIL} GET

 

Configure backend service routing URI in each policy. 

Publish all sub policies to Portal as Private policies. 

 

Advantages are:

1. Metrics collection at each HTTP method level. 

2. If POST Policy is down due to some reason other policies are still available. 

 

Which is the best practice to implement in Gateways?

What are the advantages and disadvantages of each approach. 

 

I am not sure up to what extent I have conveyed my understanding but tried to place as much as possible. Attached is the image with simple diagram for both the patterns. 

 

Regards

Kareem

Attachments

Outcomes