Claim based routing / partition routing #1816
Replies: 4 comments 3 replies
-
@mogliang thanks for your interest in Ocelot! At the moment you cannot do this with Ocelot. However it is an interesting idea. I will think about it and get back to you ASAP! |
Beta Was this translation helpful? Give feedback.
-
Expected Behavior / New Feature Actual Behavior / Motivation for New Feature Steps to Reproduce the Problem |
Beta Was this translation helpful? Give feedback.
-
I managed to get this working with the current version of Ocelot, just by adding a custom AspNetCore middleware before Ocelot in the pipeline: public class HostNameByTenantHeaderMiddleware
{
private readonly RequestDelegate _next;
public HostNameByTenantHeaderMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
var tenantId = context.Request.Headers["SomeHeaderThatConainsTheTenantId"].ToString();
if (!string.IsNullOrEmpty(tenantId))
{
context.Request.Host = HostString.FromUriComponent(tenantId);
}
await _next(context);
}
} In your Ocelot.json you can use the It should be easy to change this to substract the TenantId from a claim. |
Beta Was this translation helpful? Give feedback.
-
Hi Mog!
If you want then start to contribute! And fork the Ocelot repo first...
Sure thing! |
Beta Was this translation helpful? Give feedback.
-
Expected Behavior / New Feature
we have one service with several deployed instances, each instances serve a group of users. we use this way to do horizontal scaling.
Right now, we want to use gateway as the single api address for all instances, each http request will attach token with claim which indicates the userid. I'm wondering if Ocelot can help on this scenario?
Actual Behavior / Motivation for New Feautre
Specifications
Beta Was this translation helpful? Give feedback.
All reactions