This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-http.git


The following commit(s) were added to refs/heads/main by this push:
     new ffc7e23ff Reintroduce a way for tests to invoke a route without error 
handler (#967)
ffc7e23ff is described below

commit ffc7e23ffd3888f4c1bd9342d7fee728ce16615f
Author: PJ Fanning <[email protected]>
AuthorDate: Sat Feb 28 21:55:57 2026 +0100

    Reintroduce a way for tests to invoke a route without error handler (#967)
    
    * Initial plan
    
    * Copy akka-http PR #4219: Add toFunctionPassThroughExceptions to RouteTest
    
    Co-authored-by: pjfanning <[email protected]>
    
    * Document toFunctionPassThroughExceptions with @since
    
    Add @since annotation to toFunctionPassThroughExceptions method.
    
    ---------
    
    Co-authored-by: copilot-swe-agent[bot] 
<[email protected]>
    Co-authored-by: pjfanning <[email protected]>
---
 .../pekko/http/scaladsl/testkit/RouteTest.scala    | 22 +++++++++++++++++++---
 .../apache/pekko/http/scaladsl/server/Route.scala  |  2 +-
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git 
a/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTest.scala
 
b/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTest.scala
index 2bbde91bd..4ed18506c 100644
--- 
a/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTest.scala
+++ 
b/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTest.scala
@@ -20,7 +20,7 @@ import scala.reflect.ClassTag
 import scala.util.DynamicVariable
 
 import org.apache.pekko
-import pekko.actor.ActorSystem
+import pekko.actor.{ ActorSystem, ClassicActorSystemProvider }
 import pekko.http.scaladsl.Http
 import pekko.http.scaladsl.client.RequestBuilding
 import pekko.http.scaladsl.model._
@@ -224,8 +224,24 @@ trait RouteTest extends RequestBuilding with 
WSTestRequestBuilding with RouteTes
       }
   }
 }
-private[http] object RouteTest {
-  def runRouteClientServer(request: HttpRequest, route: Route, serverSettings: 
ServerSettings)(
+object RouteTest {
+
+  /**
+   * Turn the route into a function for testing, but do not handle exceptions 
in any way, instead, they are bubbled
+   * out as is to the caller.
+   * @since 1.4.0
+   */
+  def toFunctionPassThroughExceptions(route: Route)(
+      implicit system: ClassicActorSystemProvider): HttpRequest => 
Future[HttpResponse] = {
+    val routingLog = RoutingLog(system.classicSystem.log)
+    val routingSettings = RoutingSettings(system)
+    val parserSettings = ParserSettings.forServer
+    implicit val ec: ExecutionContextExecutor = system.classicSystem.dispatcher
+    implicit val mat: Materializer = SystemMaterializer(system).materializer
+    Route.createAsyncHandler(route, routingLog, routingSettings, 
parserSettings)
+  }
+
+  private[http] def runRouteClientServer(request: HttpRequest, route: Route, 
serverSettings: ServerSettings)(
       implicit system: ActorSystem): Future[HttpResponse] = {
     import system.dispatcher
     for {
diff --git 
a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Route.scala 
b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Route.scala
index cbacfdea0..bbd20d423 100644
--- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Route.scala
+++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Route.scala
@@ -85,7 +85,7 @@ object Route {
       SystemMaterializer(system).materializer)
   }
 
-  private def createAsyncHandler(sealedRoute: Route, routingLog: RoutingLog, 
routingSettings: RoutingSettings,
+  private[pekko] def createAsyncHandler(sealedRoute: Route, routingLog: 
RoutingLog, routingSettings: RoutingSettings,
       parserSettings: ParserSettings)(
       implicit ec: ExecutionContextExecutor, mat: Materializer): HttpRequest 
=> Future[HttpResponse] = {
     request =>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to