Question - Can two FastEndpoints co-exist?
See original GitHub issueHello,
This might be a very dumb question, but I can’t seem to figure it out by myself.
I have an application which dynamically loads multiple assemblies. Two of these assemblies wants to expose a FastEndpoints REST api. One using one port, and one using another port. They have no knowledge of each other and does not share any endpoints. The only thing they share is the same folder location on disc.
However, I have a hard time getting the “second one” (i.e. the one that is initiated after the first one) to just care about its own endpoints.
The “second one” looks somthing like the code below. I would expect it to find 0 endpoints. However, it seems to be finding endpoints from the “first” assembly (i.e. the assembly that was initiated first), which I do not expect.
var builder = WebApplication.CreateBuilder();
builder.Host.ConfigureServices((context, services) =>
{
// Adding some private services references.
});
builder.Services.AddFastEndpoints(config =>
{
config.DisableAutoDiscovery = true;
config.Assemblies = new List<Assembly>();
});
application = builder.Build();
application.UseFastEndpoints(config =>
{
config.Endpoints.Filter = ep =>
{
return false;
};
});
But as soon as the code leaves the UseFastEndpoints
function I get an exception with something to the effect of
Unable to resolve service for type 'IRestApiSettings' while attempting to activate 'MeasuementStoreValueEndpoint'.
This interface (IRestApiSettings
) and this endpoint (MeasuementStoreValueEndpoint
) is located in another assembly that I have not added and that has no service registred and thus should not even be considered as an endpoint in my mind. However, the assembly where the endpoint MeasuementStoreValueEndpoint
does exists is in the same location as where FastEndpoints is (most likely) scanning for assemblies.
I’m probably doing some silly newbie mistake so anything that could give me even the slightest hint of what I’m doing wrong is greatly appreciated.
King regards Magnus
Issue Analytics
- State:
- Created 10 months ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
see this attached project. you can use the endpoint filter to exclude/include endpoints from registration. no matter how the assemblies are loaded/discovered.
if that’s not what you’re after, pls update the project and send back to showcase the requirement.
i don’t quite have the capacity these days to look in to that. if you have some time, maybe have a crack at a PR.