当我正在阅读弹簧云Netflix文档时,我发现了一种在HTTP服务器和它的客户端之间共享接口的方法。他们将此示例用于微服务,但没有理由不能将其扩展到一般HTTP通信:
// The shared interface, in a common library
public interface UserService {
@RequestMapping(method = GET, value = "/users/{id}")
User getUser(@PathVariable long id);
}
// The controller, on the serve