1 回答

TA貢獻1847條經(jīng)驗 獲得超11個贊
如您所見,Azure 函數(shù)尚不支持可選的“中間”路由參數(shù)。只有連續(xù)的可選參數(shù)像SomeRoute/{MyOptionalRoute:int?}/{AnotherRoute:int?}
作品。
回到正題,找一個帶有代理函數(shù)的解決方法,看看是否滿足你的要求。
將 a 添加proxies.json
到您的函數(shù)項目,將文件屬性更改copy to output directory
為copy if newer
.
見下面的內(nèi)容,我使用0作為保留數(shù)作為空值的替代。代理定向http://localhost/api/SomeRoute/AnotherRoute到http://localhost/api/SomeRoute/0/AnotherRoute與 的模式匹配的真實 url SomeRoute/{MyOptionalRoute:int}/AnotherRoute。
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"proxy1": {
"matchCondition": {
"methods": [ "GET" ],
"route": "/api/SomeRoute/AnotherRoute"
},
"backendUri": "http://localhost/api/SomeRoute/0/AnotherRoute"
}
}
}
- 1 回答
- 0 關(guān)注
- 214 瀏覽
添加回答
舉報