diff --git a/applications/app/controllers/CrosswordsController.scala b/applications/app/controllers/CrosswordsController.scala index 8a7c5b6f904b..9e35a35948a4 100644 --- a/applications/app/controllers/CrosswordsController.scala +++ b/applications/app/controllers/CrosswordsController.scala @@ -24,6 +24,7 @@ import html.HtmlPageHelpers.ContentCSSFile import model.Cached.{RevalidatableResult, WithoutRevalidationResult} import model._ import model.dotcomrendering.pageElements.EditionsCrosswordRenderingDataModel +import model.dotcomrendering.pageElements.EditionsCrosswordRenderingDataModel.toJson import model.dotcomrendering.{DotcomRenderingDataModel, PageType} import org.joda.time.{DateTime, LocalDate} import pages.{CrosswordHtmlPage, IndexHtmlPage, PrintableCrosswordHtmlPage} @@ -315,6 +316,14 @@ class CrosswordEditionsController( } } + def digitalEditionJson: Action[AnyContent] = Action.async { implicit request => + getCrosswords + .map(parseCrosswords) + .map { crosswords => + Cached(CacheTime.Default)(RevalidatableResult.Ok(toJson(crosswords))).as("application/json") + } + } + private def getCrosswords: Future[SearchResponse] = contentApiClient.getResponse(crosswordsQuery) diff --git a/applications/conf/routes b/applications/conf/routes index e17e9272bd65..2cc50e84c62f 100644 --- a/applications/conf/routes +++ b/applications/conf/routes @@ -29,6 +29,7 @@ GET /crosswords/lookup # Crosswords digital edition GET /crosswords/digital-edition controllers.CrosswordEditionsController.digitalEdition +GET /crosswords/digital-edition.json controllers.CrosswordEditionsController.digitalEditionJson # Email paths GET /email/form/$emailType/$listId<[0-9]+> controllers.EmailSignupController.renderForm(emailType: String, listId: Int) diff --git a/dev-build/conf/routes b/dev-build/conf/routes index a913457e9468..8329b0371330 100644 --- a/dev-build/conf/routes +++ b/dev-build/conf/routes @@ -31,6 +31,7 @@ GET /crosswords/lookup # Crosswords digital edition GET /crosswords/digital-edition controllers.CrosswordEditionsController.digitalEdition +GET /crosswords/digital-edition.json controllers.CrosswordEditionsController.digitalEditionJson # Email paths GET /email/form/$emailType/$listId<[0-9]+> controllers.EmailSignupController.renderForm(emailType: String, listId: Int)