I am working on fixing some of this but some issues look like they need improvements in our APIs to facilitate npt needing Scala DSL or Scala lib classes in some places in Java samples.
Java DSL RouteTest that is inherited directly or indirectly by most Java tests uses Scala Durations for waits.
|
protected def defaultAwaitDuration = 3.seconds |
|
protected def awaitDuration: FiniteDuration = defaultAwaitDuration.dilated |
So far, Java users need to extend the ScalaDSL CustomHeader class or use RawHeader.
|
// FIXME discuss how to provide a javadsl.CustomHeader where render() is either pre-implemented or |
|
// trivial to write in Java |
Scala Either used in JavaDSL authenticateOrRejectWithChallenge.
Java does provide an easy replacement and our sample code that demos this shows that the Scala Either, Left and Right classes are easy to use from Java.
example:
|
final Function<Optional<HttpCredentials>, CompletionStage<Either<HttpChallenge, String>>> |
|
myUserPassAuthenticator = |
|
opt -> { |
|
if (opt.isPresent() && auth.apply(opt.get())) { |
|
return CompletableFuture.completedFuture(Right.apply("some-user-name-from-creds")); |
|
} else { |
|
return CompletableFuture.completedFuture(Left.apply(challenge)); |
|
} |
|
}; |
I am working on fixing some of this but some issues look like they need improvements in our APIs to facilitate npt needing Scala DSL or Scala lib classes in some places in Java samples.
Java DSL RouteTest that is inherited directly or indirectly by most Java tests uses Scala Durations for waits.
pekko-http/http-testkit/src/main/scala/org/apache/pekko/http/javadsl/testkit/RouteTest.scala
Lines 48 to 49 in d5f56da
So far, Java users need to extend the ScalaDSL CustomHeader class or use RawHeader.
pekko-http/http-tests/src/test/java/org/apache/pekko/http/javadsl/server/JavaRouteTest.java
Lines 32 to 33 in d5f56da
Scala Either used in JavaDSL authenticateOrRejectWithChallenge.
Java does provide an easy replacement and our sample code that demos this shows that the Scala Either, Left and Right classes are easy to use from Java.
example:
pekko-http/docs/src/test/java/docs/http/javadsl/server/directives/SecurityDirectivesExamplesTest.java
Lines 320 to 328 in d5f56da