Øys*_*ein 5 c# refit asp.net-core
我正在构建一个 API 网关,它的端点以 DateTime 值作为参数。它使用 Refit 将此查询转发到底层微服务。
我的问题是,当构建微服务查询的 URL 时,DateTime 值失去了精度。
有没有办法将 Refit 配置为在构建 URL 时使用自定义 DateTime 序列化程序?
微服务端点定义如下:
[Get("/client-sales")]
Task<ClientSaleCollectionR12n> SearchClientSales([Header("Authorization")] string authorization,
DateTime? completedAfter = null,
DateTime? completedBefore = null);
Run Code Online (Sandbox Code Playgroud)
发送到网关的查询:
GET /client-sales?completedAfter=2020-03-20T14:54:26.786&completedBefore=2020-03-21T15:16:33.212
Run Code Online (Sandbox Code Playgroud)
转发到底层微服务时就变成这样:
GET /client-sales?completedAfter=03%2F20%2F2020%2014%3A54%3A26&completedBefore=03%2F21%2F2020%2015%3A16%3A33
Run Code Online (Sandbox Code Playgroud)
我能够在定义接口时指定格式。
Task<ClientSaleCollectionR12n> SearchClientSales([Header("Authorization")] string authorization,
[Query(Format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'")] DateTime? completedAfter = null,
[Query(Format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'")] DateTime? completedBefore = null);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1893 次 |
最近记录: |