src/main/scala/s3/website/model/Config.scala in s3_website-2.9.0 vs src/main/scala/s3/website/model/Config.scala in s3_website-2.10.0

- old
+ new

@@ -13,11 +13,11 @@ s3_secret: Option[String], // If undefined, use IAM Roles (http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-roles.html) s3_bucket: String, s3_endpoint: S3Endpoint, site: Option[String], max_age: Option[Either[Int, Map[String, Int]]], - cache_control: Option[String], + cache_control: Option[Either[String, Map[String, String]]], gzip: Option[Either[Boolean, Seq[String]]], gzip_zopfli: Option[Boolean], ignore_on_server: Option[Either[String, Seq[String]]], exclude_from_upload: Option[Either[String, Seq[String]]], s3_reduced_redundancy: Option[Boolean], @@ -79,9 +79,23 @@ case maxAge if maxAge.isInstanceOf[java.util.Map[_,_]] => Right(maxAge.asInstanceOf[java.util.Map[String,Int]].toMap) }) } yamlValue getOrElse Left(ErrorReport(s"The key $key has to have an int or (string -> int) value")) + } + + def loadCacheControl(implicit unsafeYaml: UnsafeYaml): Either[ErrorReport, Option[Either[String, Map[String, String]]]] = { + val key = "cache_control" + val yamlValue = for { + cacheControlOption <- loadOptionalValue(key) + } yield { + Right(cacheControlOption.map { + case cacheControl if cacheControl.isInstanceOf[String] => Left(cacheControl.asInstanceOf[String]) + case cacheControl if cacheControl.isInstanceOf[java.util.Map[_,_]] => Right(cacheControl.asInstanceOf[java.util.Map[String,String]].toMap) // TODO an unsafe call to asInstanceOf + }) + } + + yamlValue getOrElse Left(ErrorReport(s"The key $key has to have a string or (string -> string) value")) } def loadEndpoint(implicit unsafeYaml: UnsafeYaml): Either[ErrorReport, Option[S3Endpoint]] = loadOptionalString("s3_endpoint").right flatMap { endpointString => endpointString.map(S3Endpoint.forString) match { \ No newline at end of file