This file contains hidden or 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
| namespace HomeController | |
| { | |
| [ApiVersion("1.0", Deprecated = true)] | |
| [Route("api/Values")] | |
| public class HomeController : Controller | |
| { | |
| [HttpGet] | |
| public IEnumerable<string> Get() | |
| { | |
| return new string[] { "Value1 from Version 1", "value2 from Version 1" }; |
This file contains hidden or 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
| # ASP.NET Core (.NET Framework) | |
| # Build and test ASP.NET Core projects targeting the full .NET Framework. | |
| # Add steps that publish symbols, save build artifacts, and more: | |
| # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core | |
| trigger: | |
| - dev | |
| pool: | |
| vmImage: 'Ubuntu-16.04' |
This file contains hidden or 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
| $packageName = Get-VstsInput -Name 'packageName' -Require | |
| $maxIncrement = Get-VstsInput -Name 'maxIncrement' -Require | |
| $pipelineVariable = Get-VstsInput -Name 'pipelineVariable' -Require | |
| Write-Host "The Package in use is: " $packageName | |
| Write-Host "The Max Increment version is: " $maxIncrement | |
| #Add Package Source | |
| Write-Host "Adding Nuget Package Source" | |
| Register-PackageSource -Name NuGet -Location https://www.nuget.org/api/v2 -ProviderName NuGet |
This file contains hidden or 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
| public static IServiceCollection AddRedis(this IServiceCollection services, IConfiguration configuration) | |
| { | |
| var redisCacheSettings = new RedisOptions(); | |
| configuration.GetSection(SectionName).Bind(redisCacheSettings); | |
| services.AddSingleton(redisCacheSettings); | |
| if (!redisCacheSettings.Enabled) | |
| { | |
| return services; | |
| } |
This file contains hidden or 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
| public class ResponseCacheService : IResponseCacheService | |
| { | |
| private readonly IDistributedCache _distributedCache; | |
| public ResponseCacheService(IDistributedCache distributedCache) | |
| { | |
| _distributedCache = distributedCache; | |
| } | |
| public async Task CacheResponseAsync(string cacheKey, object response, TimeSpan timeTimeLive) |
This file contains hidden or 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
| [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] | |
| public class CachedAttribute : Attribute, IAsyncActionFilter | |
| { | |
| private readonly int _timeToLiveSeconds; | |
| public CachedAttribute(int timeToLiveSeconds) | |
| { | |
| _timeToLiveSeconds = timeToLiveSeconds; | |
| } |
This file contains hidden or 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
| COPY *.csproj . | |
| RUN dotnet restore | |
| # Copy everything else and build | |
| COPY . . | |
| RUN dotnet publish -c Release -o out |
This file contains hidden or 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
| public static IServiceCollection AddConsul(this IServiceCollection serviceCollection) | |
| { | |
| IConfiguration configuration; | |
| using (var serviceProvider = serviceCollection.BuildServiceProvider()) | |
| { | |
| configuration = serviceProvider.GetService<IConfiguration>(); | |
| } | |
| ConsulOptions consulConfigOptions = configuration.GetOptions<ConsulOptions>("Consul"); | |
| serviceCollection.Configure<ConsulOptions>(configuration.GetSection("Consul")); |
This file contains hidden or 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
| public class ConsulHttpClient : IConsulHttpClient | |
| { | |
| private readonly HttpClient _client; | |
| private IConsulClient _consulclient; | |
| public ConsulHttpClient(HttpClient client, IConsulClient consulclient) | |
| { | |
| _client = client; | |
| _consulclient = consulclient; | |
| } |
This file contains hidden or 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
| [HttpGet("{customerid}")] | |
| [Cached(Constants.Day_In_Seconds)] | |
| public async Task<IActionResult> GetCustomerBasket(Guid customerid) | |
| { | |
| var basket = await _consulHttpClient.GetAsync<BasketDto>("basket-service", $"/basket/{customerid}"); | |
| return Ok(basket); | |
| } |