Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ocelot API Gateway Optional Parameter

Is there a way to tell Ocelot that a parameter is optional?

Let's say the query param below is optional:

"DownstreamPathTemplate": "/api/SearchAPI/?query={query}",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
    {
        "Host": "localhost",
        "Port": 5000
    }
],
"UpstreamPathTemplate": "/api/SearchAPI/?query={query}",
"UpstreamHttpMethod": [ "GET" ],
"FileCacheOptions": {
    "TtlSeconds": 60
}

If I send a request to /SearchAPI/?query= I get a 404 as response. I need to duplicate the Upstream to not use the param to fix. Is there another way to fix that?

like image 350
Izzy Rodriguez Avatar asked Nov 30 '25 03:11

Izzy Rodriguez


1 Answers

You can use {everything} like

"DownstreamPathTemplate": "/api/SearchAPI/{everything}"
like image 179
Roman Marusyk Avatar answered Dec 02 '25 19:12

Roman Marusyk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!