-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added new demo web project * FIxed demo project to be MVC * Added feature flags to demo website * Hid unneeded feature flag * Enabled CORS again * Cors update * removed credentials * tweak to any origin * Fixed typo in service * Added feature flag for vertical products to demo
- Loading branch information
1 parent
b83e6dc
commit 935c3f4
Showing
65 changed files
with
40,460 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
FeatureFlags/FeatureFlagsDemo.Web/Controllers/FeatureFlagsServiceApiClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
namespace FeatureFlagsDemo.Web.Controllers | ||
{ | ||
public class FeatureFlagsServiceApiClient : IFeatureFlagsServiceApiClient | ||
{ | ||
private readonly IConfiguration _configuration; | ||
private readonly HttpClient _client; | ||
|
||
public FeatureFlagsServiceApiClient(IConfiguration configuration) | ||
{ | ||
_configuration = configuration; | ||
_client = new HttpClient | ||
{ | ||
BaseAddress = new Uri(_configuration["AppSettings:FeatureFlagsWebServiceURL"]) | ||
}; | ||
} | ||
|
||
public async Task<bool> CheckFeatureFlag(string name, string environment) | ||
{ | ||
if (environment.ToLower().StartsWith("dev") == true) | ||
{ | ||
environment = "dev"; | ||
} | ||
else if (environment.ToLower().StartsWith("qa") == true || environment.ToLower().StartsWith("test") == true) //sometimes we have a test environment that we want to use qa settings | ||
{ | ||
environment = "qa"; | ||
} | ||
else if (environment.ToLower().StartsWith("prod") == true) | ||
{ | ||
environment = "prod"; | ||
} | ||
else if (environment.ToLower().StartsWith("pr") == true) //last so that it doesn't trigger with prod. :P | ||
{ | ||
environment = "pr"; | ||
} | ||
Uri url = new($"api/FeatureFlags/CheckFeatureFlag?name=" + name + "&environment=" + environment, UriKind.Relative); | ||
return await ReadMessageItem(url); | ||
} | ||
|
||
private async Task<bool> ReadMessageItem(Uri url) | ||
{ | ||
HttpResponseMessage response = await _client.GetAsync(url); | ||
if (response.IsSuccessStatusCode == false) | ||
{ | ||
return (bool)false; | ||
} | ||
else | ||
{ | ||
string bodyContent = await response.Content.ReadAsStringAsync(); | ||
return JsonConvert.DeserializeObject<bool>(bodyContent); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.