-
Notifications
You must be signed in to change notification settings - Fork 4
Client Getting Started
patriciamazere edited this page Aug 14, 2019
·
6 revisions
Once the client has been installed in your application, the following mandatory keys have to be added in the application configuration file:
- The application name
- The environment name
- The API used in order to retrieve the feature toggles (Moggles server)
<appSettings>
<!--REQUIRED KEYS-->
<add key="Moggles.ApplicationName" value="MogglesExampleApp" />
<add key="Moggles.Environment" value="DEV" />
<add key="Moggles.Url" value="http://myFeatureToggleSource.com/api/FeatureToggles/getApplicationFeatureToggles" />
</appSettings>
"Moggles": {
//REQUIRED KEYS
"ApplicationName": "MogglesExampleApp",
"Environment": "DEV",
"Url": "http://myFeatureToggleSource.com/api/FeatureToggles/getApplicationFeatureToggles"
}
After the values are added in the configuration file, the startup method of MogglesClient has to be called at application start. The method will initialize the client and it will cache the feature toggles.
Global.asax
using MogglesClient.PublicInterface;
public void Application_Start()
{
Moggles.ConfigureAndStartClient();
}
The IConfiguration object will have to be passed to the method.
Startup.cs
using MogglesClient.PublicInterface;
public void ConfigureServices(IServiceCollection services)
{
Moggles.ConfigureAndStartClient(Configuration);
}
The only thing left to do is to add a feature toggle.
Each feature toggle needs to have a corresponding class that inherits from MogglesFeatureToggle
. The feature toggle class name has to be the same as the feature toggle added in Moggles server.
using MogglesClient.PublicInterface;
namespace TestApp.FeatureToggles
{
public class TestFeatureToggle: MogglesFeatureToggle
{
}
}
Usage:
if (Is<TestFeatureToggle>.Enabled)
{
...
}