Migrating from custom gateway API in dotnet 6 to YARP #2668
-
I have a dotnet 6 API project that acts as a gateway. This gateway project has controllers that accept the request and then send the request to our microservices via SDKs we have for them. I am now trying to implement YARP so that devs don't have to write code in our gateway whenever they have created a new endpoint in one of the microservices. However we have consumers for our existing endpoints in gateway and over last couple of months they are a bit of mess. There isn't a common convention for them. So I wrote a config as seen below
The problem I face is some that with this config some of the actions hit controllers in my project but some are being proxied. For example I have below two endpoints:
The second one hit my breakpoint in controller but the first one is proxied and forwarded to my microservice and fails as the endpoint isn't available. I see below log lines
The one that works logs this
What might be wrong here. Both controller have similar signature with route and action. I use serilog and added below config but I don't think i am seeing any logs related to YARP
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
After breaking my head over this for some time I found the problem to be Consumes and Produces attribute I had on controller :|
Update: |
Beta Was this translation helpful? Give feedback.
The
ConsumesAttribute
is a routing filter. If the incoming request does not have the appropriateContentType
set, your action won't be considered. Valid requests should not be impacted as your controller will remain a valid routing candidate.Is the thing that's broken that you were testing that invalid requests result in a 415 response?