Closed dazinator closed 6 years ago
Thanks for contacting us, @dazinator. @JamesNK, can you please look into this? Thanks!
Hi
Do you mean forking the pipeline using Map? If so then this is supported:
app.Map("/Branch1", branch =>
{
branch.UseEndpointRouting(routes =>
{
//
});
});
app.Map("/Branch2", branch =>
{
branch.UseEndpointRouting(routes =>
{
//
});
});
Thanks for the clarification, looks like that should cater for different tenants having different endpoints.
Just occured to me, to extend the question a little, where / how would mvc's attribute routing fit into your endpoints example above?
Like this:
app.Map("/Branch1", branch =>
{
branch.UseEndpointRouting(routes =>
{
routes.MapMvcApplication(); // registers attribute routed MVC actions
});
});
Do you have UseMvc nested inside Map today? Could you give a simplified example? e.g. the startup.cs code related to branching and MVC, along with example URLs.
I was paranoid that we have never tested endpoint routing in branching. Test to confirmed it works - https://github.com/aspnet/Routing/pull/905 😸
Thanks for the test coverage :-)
In the test, I noticed the additional call to app.UseEndpoint();
- wondered why you need to UseEndpoint
and UseEndpointRouting
?
UseEndpointRouting = matching endpoint UseEndpoint = execute endpoint
Not sure if you need this, but I fork the middleware pipeline slightly differently, not using Map, as seen here: https://github.com/dazinator/Dotnettency/blob/develop/src/Dotnettency.AspNetCore.MiddlewarePipeline/DelegateTenantMiddlewarePipelineFactory.cs#L27
However I think it should be similar conceptually. There is a sample app that can be run in the same repo showing multitenant app in action. I'll close this for now as my question is answered (thanks).
UseEndpointRouting = matching endpoint UseEndpoint = execute endpoint
got ya, cheers
Reading this:
With traditional routing, you can fork the http middleware pipeline, for example, per tenant, and then on each fork of the pipeline you can
UseRouting
with a router configured with routes for the specific tenant. This provides nice isolation of tenant routes.What's the story with EndPoint routing in terms of having per tenant route tables / graphs? Will this concept still apply?