43 lines
1.2 KiB
Java
Raw Normal View History

2016-02-07 17:05:33 -06:00
package com.iluwatar.api.gateway;
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.
*/
@RestController
2016-02-07 17:05:33 -06:00
public class ApiGateway {
@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
*/
@RequestMapping("/desktop")
2016-02-07 17:05:33 -06:00
public DesktopProduct getProductDesktop() {
DesktopProduct desktopProduct = new DesktopProduct();
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
*/
@RequestMapping("/mobile")
2016-02-07 17:05:33 -06:00
public MobileProduct getProductMobile() {
MobileProduct mobileProduct = new MobileProduct();
mobileProduct.setPrice(priceClient.getPrice());
2016-02-07 17:05:33 -06:00
return mobileProduct;
}
}