Skip to content

Commit

Permalink
Merge branch 'main' into Development
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWhittington authored Oct 7, 2024
2 parents 0423354 + 8886e15 commit 8a927cb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/Dfe.ContentSupport.Web/Controllers/ContentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ContentController(
: Controller
{
public const string ErrorActionName = "error";

[HttpGet("{slug}/{page?}")]
public async Task<IActionResult> Index(string slug, string page = "", bool isPreview = false,
[FromQuery] List<string>? tags = null)
Expand Down Expand Up @@ -60,7 +60,6 @@ public async Task<IActionResult> Index(string slug, string page = "", bool isPre
}
}


[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Polly;
using Polly.Extensions.Http;

namespace Dfe.ContentSupport.Web.Extensions;

public static class HttpClientPolicyExtensions
{
public static void AddRetryPolicy(IHttpClientBuilder builder) =>
builder
.SetHandlerLifetime(TimeSpan.FromMinutes(5))
.AddPolicyHandler(GetRetryPolicy());

public static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy() =>
HttpPolicyExtensions.HandleTransientHttpError()
.OrResult(msg => msg.StatusCode == System.Net.HttpStatusCode.NotFound)
.WaitAndRetryAsync(6, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Contentful.Core;
using Contentful.Core;
using Contentful.Core.Configuration;
using Dfe.ContentSupport.Web.Configuration;
using Dfe.ContentSupport.Web.Models.Mapped;
Expand Down
2 changes: 1 addition & 1 deletion src/Dfe.ContentSupport.Web/Services/ModelMapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Contentful.Core.Models;
using Contentful.Core.Models;
using Dfe.ContentSupport.Web.Common;
using Dfe.ContentSupport.Web.Configuration;
using Dfe.ContentSupport.Web.Models;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Contentful.Core;
using Contentful.Core;
using Contentful.Core.Configuration;
using Contentful.Core.Models;
using Dfe.ContentSupport.Web.Extensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Dfe.ContentSupport.Web.Extensions;
using Dfe.ContentSupport.Web.Extensions;
using Dfe.ContentSupport.Web.Models.Mapped;
using Microsoft.AspNetCore.Builder;

Expand Down

0 comments on commit 8a927cb

Please sign in to comment.