2016-02-07 17:05:33 -06:00
|
|
|
package com.iluwatar.api.gateway;
|
|
|
|
|
2016-04-02 18:25:13 -05:00
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
2016-02-07 17:05:33 -06:00
|
|
|
/**
|
|
|
|
* The ApiGateway aggregates calls to microservices based on the needs of the individual clients.
|
|
|
|
*/
|
2016-04-02 18:25:13 -05:00
|
|
|
@RestController
|
2016-02-07 17:05:33 -06:00
|
|
|
public class ApiGateway {
|
|
|
|
|
2016-04-02 18:25:13 -05:00
|
|
|
@Resource
|
|
|
|
private ImageClient imageClient;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private PriceClient priceClient;
|
2016-02-07 17:05:33 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves product information that desktop clients need
|
|
|
|
* @return Product information for clients on a desktop
|
|
|
|
*/
|
2016-04-02 18:25:13 -05:00
|
|
|
@RequestMapping("/desktop")
|
2016-02-07 17:05:33 -06:00
|
|
|
public DesktopProduct getProductDesktop() {
|
|
|
|
DesktopProduct desktopProduct = new DesktopProduct();
|
2016-04-02 18:25:13 -05:00
|
|
|
desktopProduct.setImagePath(imageClient.getImagePath());
|
|
|
|
desktopProduct.setPrice(priceClient.getPrice());
|
2016-02-07 17:05:33 -06:00
|
|
|
return desktopProduct;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves product information that mobile clients need
|
|
|
|
* @return Product information for clients on a mobile device
|
|
|
|
*/
|
2016-04-02 18:25:13 -05:00
|
|
|
@RequestMapping("/mobile")
|
2016-02-07 17:05:33 -06:00
|
|
|
public MobileProduct getProductMobile() {
|
|
|
|
MobileProduct mobileProduct = new MobileProduct();
|
2016-04-02 18:25:13 -05:00
|
|
|
mobileProduct.setPrice(priceClient.getPrice());
|
2016-02-07 17:05:33 -06:00
|
|
|
return mobileProduct;
|
|
|
|
}
|
|
|
|
}
|