ThreeMammals / Ocelot

.NET API Gateway

Home Page:https://www.nuget.org/packages/Ocelot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Injection middleware not working

jorge-ribeiro opened this issue · comments

I have an ocelot web api solution in which requests must be checked by a captchamiddleware to verify if they have the proper custom captcha key/value in a request header, before the request is forwarded to business entities webapis.
When captcha is not present or invalid an error response is sent back. I also have to be able to get the selected downstream route in order to get some metadata from ocelot.json.

The thing is when i add my middleware like:

app.UseMiddleware<CaptchaPayloadMiddleware>();
app.UseOcelot().Wait();

the response is sent back nicely but i cannot access route info, and when i add my middleware like:

app.UseOcelot().Wait();
app.UseMiddleware<CaptchaPayloadMiddleware>();

i have access to route info, but cannot change response as it already started (it sends the response anyway but with an ugly warning - ReasonPhrase cannot be set because the response has already started).

Is this even possible to do with Ocelot?
If so can you help me here?

Thanks

Regards

Hi Jorge!
Why did you create issue when you need just create Q&A discussion to ask your questions?