How i can add endpoint (or сatch a request and check its path) to BCL?

57 views Asked by At

I need to create a BCL that will automatically add a path to /api/environment, for example, in order to subsequently reuse this library by adding the same path to all projects that will do the same logic, for example, give the current environment of the application.

Initially I thought of doing this through middleware, or a minimal api, simply catching a specific request and processing it. But Microsoft.AspNetCore.App.Ref is not available in BCL. Then I came to the conclusion that I needed to somehow catch the request, but I didn’t find a single library that would help me do this.

1

There are 1 answers

0
Marc Gravell On BEST ANSWER

If you're in a class library and want access to the asp.net core bits, add a framework reference in the csproj:

<ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>