Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions media-api/app/MediaApiComponents.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class MediaApiComponents(context: Context) extends GridComponents(context, new M
val usageController = new UsageController(auth, config, elasticSearch, usageQuota, controllerComponents)
val elasticSearchHealthCheck = new ElasticSearchHealthCheck(controllerComponents, elasticSearch)
val healthcheckController = new Management(controllerComponents, buildInfo)
val configurationController = new ConfigurationController(controllerComponents)
val InnerServiceStatusCheckController = new InnerServiceStatusCheckController(auth, controllerComponents, config.services, wsClient)

override val router = new Routes(
Expand All @@ -45,6 +46,7 @@ class MediaApiComponents(context: Context) extends GridComponents(context, new M
suggestionController,
aggController,
usageController,
configurationController,
elasticSearchHealthCheck,
healthcheckController,
InnerServiceStatusCheckController
Expand Down
11 changes: 11 additions & 0 deletions media-api/app/controllers/ConfigurationController.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package controllers

import lib.crops.CropOption
import play.api.libs.json.Json
import play.api.mvc.{BaseController, ControllerComponents}

class ConfigurationController(override val controllerComponents: ControllerComponents) extends BaseController {
// The contents of this endpoint is not sensitive, so to avoid unnecessary complexity we have not
// put authentication on this
def cropVariations = Action { _ => Ok(Json.toJson(CropOption.supported)) }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth a brief comment that this is intentionally without auth, for future travellers who might think it was an oversight and attempt to correct

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sounds good 👍

}
15 changes: 15 additions & 0 deletions media-api/app/lib/crops/CropOption.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package lib.crops

import play.api.libs.json.{Json, OFormat}

case class CropOption(key: String, ratio: String, ratioString: String)

object CropOption {
implicit val jf: OFormat[CropOption] = Json.format[CropOption]
val supported = List(
CropOption("landscape", "5 / 4", "5:4"),
CropOption("portrait", "4 / 5", "4:5"),
CropOption("video", "16 / 9", "16:9"),
CropOption("square", "1", "1:1"),
)
}
3 changes: 3 additions & 0 deletions media-api/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ GET /usage/suppliers/:id controllers.
GET /usage/quotas controllers.UsageController.quotas
GET /usage/quotas/:id controllers.UsageController.quotaForImage(id: String)

# configuration
GET /configuration/crop-variations controllers.ConfigurationController.cropVariations

# Management
GET /management/healthcheck com.gu.mediaservice.lib.management.ElasticSearchHealthCheck.healthCheck
GET /management/manifest com.gu.mediaservice.lib.management.Management.manifest
Expand Down
Loading