I want to know the standard way of designing API calls URL to Microservices. I have 2 microservices Example- User, Order. APIs created will be used in my application UI and also for any third-party integration. Which Url pattern should I follow:
METHOD1: Hide internal microservice implementaion
To create user:
POST: /user (Call goes to User Service)
To get user:
GET: /user/{userId} (Call goes to User Service)
To create order for user
POST: /user/{userId}/order (Call goes to Order Service and order service internally validate user with user service)
To get user order by id
GET: /user/{userId}/order/{orderId} (Call goes to Order Service and order service internally validate user with user service)
METHOD2: Each API has details of which Microservice it belongs to
To create user:
POST: /userService/user (Call goes to User Service)
To get user:
GET: /userService/user/{userId} (Call goes to User Service)
To create order for user
POST: /orderService/order (Call goes to Order Service with userId in Request Body and order service internally validate user with user service)
To get user order by id
GET: /orderService/order/{orderId} (Call goes to Order Service with userId in Request Body and order service internally validate user with user service)
Which one is good approach, also let me know if this can be done in any other different way? Thanks in Advance.