diff --git a/jpro-auth/example/src/main/java/one/jpro/platform/auth/example/login/LoginApp.java b/jpro-auth/example/src/main/java/one/jpro/platform/auth/example/login/LoginApp.java index d16b557f..757e032d 100644 --- a/jpro-auth/example/src/main/java/one/jpro/platform/auth/example/login/LoginApp.java +++ b/jpro-auth/example/src/main/java/one/jpro/platform/auth/example/login/LoginApp.java @@ -11,14 +11,12 @@ import one.jpro.platform.auth.example.login.page.SignedInPage; import one.jpro.platform.auth.example.oauth.OAuthApp; import one.jpro.platform.auth.routing.OAuth2Filter; -import one.jpro.platform.routing.Redirect; import one.jpro.platform.routing.Response; import one.jpro.platform.routing.Route; import one.jpro.platform.routing.RouteApp; import one.jpro.platform.routing.dev.DevFilter; import one.jpro.platform.sessions.SessionManager; import org.json.JSONObject; -import simplefx.experimental.parts.FXFuture; import java.net.URL; import java.util.List; @@ -84,8 +82,8 @@ public Route createRoute() { .filter(DevFilter.create()) .filter(OAuth2Filter.create(googleAuthProvider, googleCredentials, user -> { setUser(user); - return FXFuture.unit(Response.redirect("/user/signed-in")); - }, error -> FXFuture.unit(Response.fromNode(new ErrorPage(error))))); + return Response.redirectFuture("/user/signed-in"); + }, error -> Response.fromNodeFuture(new ErrorPage(error)))); } public final User getUser() { diff --git a/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Response.scala b/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Response.scala index 06740074..557ef9cc 100644 --- a/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Response.scala +++ b/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Response.scala @@ -1,10 +1,15 @@ package one.jpro.platform.routing +import simplefx.experimental.FXFuture + trait Response object Response { def empty(): Response = null + def emptyFuture(): FXFuture[Response] = FXFuture.unit(empty()) def redirect(to: String): Response = Redirect(to) + def redirectFuture(to: String): FXFuture[Response] = FXFuture.unit(Redirect(to)) def fromNode(node: javafx.scene.Node): Response = new Response { RouteUtils.viewFromNode(node) } + def fromNodeFuture(node: javafx.scene.Node): FXFuture[Response] = FXFuture.unit(fromNode(node)) } diff --git a/jpro-routing/example/src/main/java/example/colors/ColorsApp.java b/jpro-routing/example/src/main/java/example/colors/ColorsApp.java index 61ba97bd..f3ba3ab5 100644 --- a/jpro-routing/example/src/main/java/example/colors/ColorsApp.java +++ b/jpro-routing/example/src/main/java/example/colors/ColorsApp.java @@ -40,9 +40,9 @@ public Route createRoute() { if(matcher.matches()) { var colorStr = matcher.group(1); var color = Color.web(colorStr); - return FXFuture.unit(viewFromNode(gen("#" + colorStr, r.resolve("/red"), color))); + return Response.fromNodeFuture(gen("#" + colorStr, r.resolve("/red"), color)); } else { - return FXFuture.unit(null); + return Response.emptyFuture(); } }) .path("/colors",