I would like to add LaunchDarkly feature management in my .net core api.In a real time project how can i add this?
I have one interface file with all features.How will be this interface participate in LD call?
i am confused how to create a generic file for the configuration and call to different controllers! any help will be appreciated!
what I have did in my sample program..
I created a flag in the LD website and added below code to main
Configuration ldConfig = LaunchDarkly.Client.Configuration // TODO: Enter your LaunchDarkly SDK key here .Default("YOUR_SDK_KEY"); LdClient client = new LdClient(ldConfig); User user = User.Builder("[email protected]") .FirstName("Bob") .LastName("Loblaw") .Custom("groups", "beta_testers") .Build(); // TODO: Enter the key for your feature flag key here var value = client.BoolVariation("YOUR_FEATURE_FLAG_KEY", user, false); if (value) { Console.WriteLine("Showing feature for user " + user.Key); } else { Console.WriteLine("Not showing feature for user " + user.Key); }
But now i have a real time api project with huge lines of code, multiple controllers.How can i make this LD class generic? please help me..thanks
First, declare the key in appsettings.json. Then create an interface class to declare the methods you want.
Now implement this interface
Make sure to inject configuration in startup.cs
Now you can inject this IFeatureFlagService in your controllers and call like