【发布时间】:2013-09-07 03:41:03
【问题描述】:
根据 Mythz (Getting ServiceStack to retain type information),他建议不要在 DTO 中使用继承。我希望每个请求都可选地提供 API 密钥或位置参数的用例怎么样?接口不好用但抽象类可以吗?有人推荐吗?
【问题讨论】:
标签: servicestack
根据 Mythz (Getting ServiceStack to retain type information),他建议不要在 DTO 中使用继承。我希望每个请求都可选地提供 API 密钥或位置参数的用例怎么样?接口不好用但抽象类可以吗?有人推荐吗?
【问题讨论】:
标签: servicestack
您的用例“每个可选地提供 API 密钥或位置参数的请求”传统上在 SS 中通过 filter attributes 处理
Here's an example where a required authorization header is managed both server-side and client-side.
鉴于正确的要求,Mythz 建议在 DTO 中使用自定义接口:“请求 DTO 实现仅具有租户属性的自定义 ITenant 接口。另一种解决方案是使用 IHttpRequest.Tennant() 扩展方法您可以在检查 AbsoluteUri 或 RawUrl 属性的所有服务中重复使用。”看到这条评论:(Multi-tenant ServiceStack API, same deployment to respond to requests on different hostnames?)
【讨论】:
我使用接口,然后在请求过滤器中检查接口的实现。
【讨论】: