diff --git a/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpGenerator.scala b/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpGenerator.scala index 7a357e1..03a32e0 100644 --- a/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpGenerator.scala +++ b/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpGenerator.scala @@ -427,8 +427,8 @@ class PekkoHttpGenerator private (pekkoHttpVersion: PekkoHttpVersion, modelGener ( 413, pekkoHttpVersion match { - case PekkoHttpVersion.V10_1 => q"RequestEntityTooLarge" - case PekkoHttpVersion.V10_2 => q"PayloadTooLarge" + case PekkoHttpVersion.V1_0_0 => q"PayloadTooLarge" + case PekkoHttpVersion.V1_1_0 => q"ContentTooLarge" } ) ) diff --git a/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpServerGenerator.scala b/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpServerGenerator.scala index da6e47e..68c9296 100644 --- a/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpServerGenerator.scala +++ b/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpServerGenerator.scala @@ -804,19 +804,12 @@ class PekkoHttpServerGenerator private (pekkoHttpVersion: PekkoHttpVersion, mode part.entity.dataBytes.toMat(fileSink)(Keep.right).run() .transform(${Term.PartialFunction( List( - if (pekkoHttpVersion == PekkoHttpVersion.V10_1) - Some(p""" - case IOResult(_, Failure(t)) => - dest.delete() - throw t - """) - else None, - Some(p""" + p""" case IOResult(_, _) => val hash = messageDigest.map(md => javax.xml.bind.DatatypeConverter.printHexBinary(md.digest()).toLowerCase(java.util.Locale.US)) (dest, part.filename, part.entity.contentType, hash) - """) - ).flatten + """ + ) )}, { case t => dest.delete() t @@ -842,8 +835,8 @@ class PekkoHttpServerGenerator private (pekkoHttpVersion: PekkoHttpVersion, mode } val info = new ErrorInfo(summary, "Consider increasing the value of pekko.http.server.parsing.max-content-length") val status = ${pekkoHttpVersion match { - case PekkoHttpVersion.V10_1 => q"StatusCodes.RequestEntityTooLarge" - case PekkoHttpVersion.V10_2 => q"StatusCodes.PayloadTooLarge" + case PekkoHttpVersion.V1_0_0 => q"StatusCodes.PayloadTooLarge" + case PekkoHttpVersion.V1_1_0 => q"StatusCodes.ContentTooLarge" }} val msg = if (settings.verboseErrorMessages) info.formatPretty else info.summary complete(HttpResponse(status, entity = msg)) diff --git a/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpVersion.scala b/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpVersion.scala index 9ff7704..6d7942b 100644 --- a/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpVersion.scala +++ b/modules/scala-pekko-http/src/main/scala/dev/guardrail/generators/scala/pekkoHttp/PekkoHttpVersion.scala @@ -2,12 +2,12 @@ package dev.guardrail.generators.scala.pekkoHttp sealed abstract class PekkoHttpVersion(val value: String) object PekkoHttpVersion { - case object V10_1 extends PekkoHttpVersion("pekko-http-v10.1") - case object V10_2 extends PekkoHttpVersion("pekko-http-v10.2") + case object V1_0_0 extends PekkoHttpVersion("pekko-http-v1.0.0") + case object V1_1_0 extends PekkoHttpVersion("pekko-http-v1.1.0") val mapping: Map[String, PekkoHttpVersion] = Map( - "pekko-http" -> V10_2, - V10_1.value -> V10_1, - V10_2.value -> V10_2 + "pekko-http" -> V1_1_0, + V1_0_0.value -> V1_0_0, + V1_1_0.value -> V1_1_0 ) }