Skip to content

Commit

Permalink
Merge pull request #27649 from guardian/editions-crossword-json-route
Browse files Browse the repository at this point in the history
Editions crossword json route
  • Loading branch information
DanielCliftonGuardian authored Dec 5, 2024
2 parents 3cf2b3f + dc38754 commit 8b7f135
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions applications/app/controllers/CrosswordsController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions applications/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -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<plain|plaindark|plaintone>/$listId<[0-9]+> controllers.EmailSignupController.renderForm(emailType: String, listId: Int)
Expand Down
1 change: 1 addition & 0 deletions dev-build/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -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<plain|plaindark|plaintone>/$listId<[0-9]+> controllers.EmailSignupController.renderForm(emailType: String, listId: Int)
Expand Down

0 comments on commit 8b7f135

Please sign in to comment.