https://github.com/aimenux/conditionalendpointsdemo
Using various ways in order to conditionally disable endpoints
https://github.com/aimenux/conditionalendpointsdemo
action-filter conditional-endpoints feature-flags middleware net60 vs22
Last synced: about 1 month ago
JSON representation
Using various ways in order to conditionally disable endpoints
- Host: GitHub
- URL: https://github.com/aimenux/conditionalendpointsdemo
- Owner: aimenux
- Created: 2022-02-14T11:58:18.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-14T12:35:10.000Z (over 4 years ago)
- Last Synced: 2025-02-27T01:54:34.133Z (over 1 year ago)
- Topics: action-filter, conditional-endpoints, feature-flags, middleware, net60, vs22
- Language: C#
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://github.com/aimenux/ConditionalEndpointsDemo/actions/workflows/ci.yml)
# 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.
>
> :one: Using feature provider `ConditionalControllerProvider` to enable/disable endpoints based on environment.
>
> :two: Using action filter `ConditionalActionFilterAttribute` to enable/disable endpoints based on environment.
>
> :three: Using middleware `ConditionalMiddleware` to enable/disable endpoints based on environment.
>
> :four: Using [feature flags](https://github.com/microsoft/FeatureManagement-Dotnet) `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 :
>
> :heavy_minus_sign: Open file `launchSettings.json` of some project for example `01-Way`
>
> :heavy_minus_sign: Edit the appropriate profile for example `_01_Way` or `IIS Express`
>
> :heavy_minus_sign: Set variable `ASPNETCORE_ENVIRONMENT` to `Production` value
**`Tools`** : vs22, net 6.0