question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question - Can two FastEndpoints co-exist?

See original GitHub issue

Hello,

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:closed
  • Created 10 months ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dj-nitehawkcommented, Dec 6, 2022

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.

0reactions
dj-nitehawkcommented, Dec 19, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advantages and disadvantages of FastEndpoints : r/dotnet
Support for multiple serialization formats, like Thrift, Bond, gRPC, JSON, XML. Support for JWT Bearer Auth. Clean domain model.
Read more >
How to read claim values + handling multiple http verbs #8
Hi, i'm so happy to see your fastendpoints and started to use it, and still not reach at there where i can find...
Read more >
Exploring Fast Endpoints: A Better Approach to Building APIs
Are Fast Endpoints better than Minimal API? For trivial projects with one or two simple endpoints, I might still consider Minimal API. That...
Read more >
FastEndpoints and Dapper with .NET | by Poatek
It's faster, uses less memory, and does around 35k more requests per second than an MVC Controller. Dapper is an open-source object-relational mapping...
Read more >
API Versioning
FastEndpoints provides a unique, yet simplified model for versioning your endpoints to ease the developer's life.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found