Thanks for the prompt reply. I've tried the StatusCodes.custom call with a non-standard status code but it throws the following exception:
Exception in thread "main" java.lang.IllegalArgumentException: Can't register status code in non-standard region
at akka.http.scaladsl.model.StatusCodes$.custom(StatusCode.scala:92)
at AkkaHttp2$.delayedEndpoint$AkkaHttp2$1(AkkaHttp2.scala:47)
at AkkaHttp2$delayedInit$body.apply(AkkaHttp2.scala:16)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76)
at AkkaHttp2$.main(AkkaHttp2.scala:16)
at AkkaHttp2.main(AkkaHttp2.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
It seems StatusCodes.custom specifically doesn't allow codes outside the normal range:
def custom(intValue: Int, reason: String, defaultMessage: String = ""): StatusCode =
if (100 to 199 contains intValue) Informational(intValue)(reason, defaultMessage)
else if (200 to 299 contains intValue) Success(intValue)(reason, defaultMessage)
else if (300 to 399 contains intValue) Redirection(intValue)(reason, defaultMessage, defaultMessage)
else if (400 to 499 contains intValue) ClientError(intValue)(reason, defaultMessage)
else if (500 to 599 contains intValue) ServerError(intValue)(reason, defaultMessage)
else throw new IllegalArgumentException("Can't register status code in non-standard region")
Best,
Patrick