java - Java REST - 过滤要返回的信息
问题描述
是否有设计模式或众所周知的解决方案来设计 REST 服务,其中应用程序的前端可能会调用相同的 Web 服务以获取有关对象的不同信息。
例子:
WebServiceFull.class
@PATH('/car/')
public Response getCarInformation(@PathParam('id') long carId) {
// Call Service/DAO
// return the complete Car Object (may contain 50 properties for instance (color, size, age, factory, brand, ....)
}
我想知道是否可能/好:
WebServiceWanted.class
@PATH('/car/')
public Response getCarInformation(@PathParam('id') long carId, @QueryParam('info') List<String> infoWanted) {
// Call Service/DAO with the List
// Browse through the given list to only get from DataBase the needed info
// return the partially complete Car Object
}
解决方案
推荐阅读
- caching - 如何在同一个 JVM 上运行多个 Apache Ignite 节点?
- javascript - 从 JavaScript 中的模块导入模块的正确方法是什么?
- javascript - 如何在 Angular JS 的自定义标签中访问 HTML?
- javascript - JavaScript映射返回对象数组而不是ojbect
- amazon-web-services - CloudFormation 堆栈错误 - GetObject 时发生错误。S3 错误代码:NoSuchKey
- android - Firebase Analytics 显示的数据不准确
- laravel - 得到错误'试图获取非对象的属性'id''即使 dd 函数正确返回
- c# - 工厂设计模式(不同签名)
- python - 无法将一些难以辨认的内容处理为可读
- php - 如何使用 SQL 连接合并表?