asp.net-core - Ocelot API Gateway 可选参数
问题描述
有没有办法告诉 Ocelot 一个参数是可选的?
假设下面的查询参数是可选的:
"DownstreamPathTemplate": "/api/SearchAPI/?query={query}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5000
}
],
"UpstreamPathTemplate": "/api/SearchAPI/?query={query}",
"UpstreamHttpMethod": [ "GET" ],
"FileCacheOptions": {
"TtlSeconds": 60
}
如果我向我发送请求,/SearchAPI/?query=
我会得到一个404
响应。我需要复制Upstream
不使用参数来修复。还有其他方法可以解决这个问题吗?
解决方案
你可以使用{everything}
喜欢
"DownstreamPathTemplate": "/api/SearchAPI/{everything}"
推荐阅读
- c# - Json序列化在根处添加字符串元素
- html - 如何在 flexbox flex-column 类 div 中将高度设置为高于 100%?
- python - Django - 与过滤器相关的计数
- c - 我需要一种在 C 中两次读取浮点数的方法。每次都以
-d - java - 传递给新窗口的 JavaFX 参数变为 NULL
- python - Python 3:将变量的变化值传递给导入的函数库中的函数
- vhdl - vhdl 错误:在“梯子”附近:(vcom-1576)期待 IS。#
- excel - 如何从 Autofilter 中删除 Criteria2 但保留 Criteria1?
- javascript - Windows 上的 Puppeteer:按下 Meta 键时单击锚点不会按预期在新选项卡中打开链接
- python - Matplotlib 意外 contains_point() 导致嵌套圆环图