ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.24k stars 1.62k forks source link

Injection middleware not working #2115

Closed jorge-ribeiro closed 1 week ago

jorge-ribeiro commented 1 week ago

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

raman-m commented 1 week ago

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

jorge-ribeiro commented 1 week ago

Sorry... can you send me the link to Q&A? thanks!

On Thu, 4 Jul 2024 at 19:25, Raman Maksimchuk @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/ThreeMammals/Ocelot/issues/2115#issuecomment-2209436465, or unsubscribe https://github.com/notifications/unsubscribe-auth/BJU7SQGYQD2LL6VCOJYLH5LZKWHSHAVCNFSM6AAAAABKLQXPPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBZGQZTMNBWGU . You are receiving this because you authored the thread.Message ID: @.***>