Does Ocelot support conditional routing based on a header? #1998
Answered
by
raman-m
usama-azakaw
asked this question in
Q&A
-
I want to route the request only if there's a bearer token present in the header of the request. (I don't want to validate the token at Ocelot). |
Beta Was this translation helpful? Give feedback.
Answered by
raman-m
Mar 17, 2024
Replies: 1 comment
-
You want to detect Auth header but don't want to authenticate, right?
After the header detection just fail the request by status code overriding, so use some code from range 3xx-4xx. Hope it helps! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
raman-m
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You want to detect Auth header but don't want to authenticate, right?
To achieve that you could use any middleware and class which have local
HttpContext
orHttpRequest
object, mostly all classes and services where you can read Headers collection 👉context.Request.Headers
, see HttpRequest.Headersrequest.Headers
, see HttpRequestMessage.HeadersAfter the header detection just fail the request by status code overriding, so use some code from range 3xx-4xx.
Hope it helps!