gpt4 book ai didi

具有继承的 ServiceStack DTO

转载 作者:行者123 更新时间:2023-12-05 01:07:28 25 4
gpt4 key购买 nike

根据 Mythz (Getting ServiceStack to retain type information),他建议不要在 DTO 中使用继承。我希望每个请求都可选地提供 API key 或位置参数的用例怎么样?接口(interface)不好用但抽象类可以吗?有人有什么建议吗?

最佳答案

您的用例“每个可选地提供 API key 或位置参数的请求”通常在 SS 中通过 filter attributes 处理。

Here's an example where a required authorization header is managed both server-side and client-side.

考虑到正确的要求,Mythz 建议在 DTO 中使用自定义接口(interface):“Request DTO that implementations a custom ITenant interface that just has an Tenant property. 另一种解决方案是使用 IHttpRequest.Tennant() 扩展方法,您可以重新- 在所有检查 AbsoluteUri 或 RawUrl 属性的服务中使用。”看到这条评论:(Multi-tenant ServiceStack API, same deployment to respond to requests on different hostnames?)

关于具有继承的 ServiceStack DTO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18669452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com