Skip to content

aimenux/ConditionalEndpointsDemo

Repository files navigation

.NET

ConditionalEndpointsDemo

Using various ways in order to conditionally disable endpoints

In this demo, i m using various ways in order to disable some endpoints in production environment.

1️⃣ Using feature provider ConditionalControllerProvider to enable/disable endpoints based on environment.

2️⃣ Using action filter ConditionalActionFilterAttribute to enable/disable endpoints based on environment.

3️⃣ Using middleware ConditionalMiddleware to enable/disable endpoints based on environment.

4️⃣ Using feature flags ConditionalFeatureFilter to enable/disable endpoints based on environment.

The first way is the simplest one in my opinion. The other ways needs more code to disable endpoints also in swagger.

In order to simulate the behaviour in production environment :

➖ Open file launchSettings.json of some project for example 01-Way

➖ Edit the appropriate profile for example _01_Way or IIS Express

➖ Set variable ASPNETCORE_ENVIRONMENT to Production value

Tools : vs22, net 6.0

About

Using various ways in order to conditionally disable endpoints

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages