diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index b4d5504f526e0..018b9f5a9e7bf 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -296,7 +296,7 @@ public static void startServerAfterFailedStart() { if (liveReloadConfig.password().isPresent() && hotReplacementContext.getDevModeType() == DevModeType.REMOTE_SERVER_SIDE) { root = remoteSyncHandler = new RemoteSyncHandler(liveReloadConfig.password().get(), root, - hotReplacementContext); + hotReplacementContext, "/"); } rootHandler = root; @@ -547,7 +547,8 @@ public void handle(RoutingContext event) { } if (launchMode == LaunchMode.DEVELOPMENT && liveReloadConfig.password().isPresent() && hotReplacementContext.getDevModeType() == DevModeType.REMOTE_SERVER_SIDE) { - root = remoteSyncHandler = new RemoteSyncHandler(liveReloadConfig.password().get(), root, hotReplacementContext); + root = remoteSyncHandler = new RemoteSyncHandler(liveReloadConfig.password().get(), root, hotReplacementContext, + rootPath); } rootHandler = root; diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/RemoteSyncHandler.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/RemoteSyncHandler.java index 059a1dcea9aaa..37ecd938f6bd8 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/RemoteSyncHandler.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/RemoteSyncHandler.java @@ -38,6 +38,7 @@ public class RemoteSyncHandler implements Handler { final String password; final Handler next; final HotReplacementContext hotReplacementContext; + final String rootPath; //all these are static to allow the handler to be recreated on hot reload //which makes lifecycle management a lot easier @@ -48,10 +49,12 @@ public class RemoteSyncHandler implements Handler { static volatile Throwable remoteProblem; static volatile boolean checkForChanges; - public RemoteSyncHandler(String password, Handler next, HotReplacementContext hotReplacementContext) { + public RemoteSyncHandler(String password, Handler next, HotReplacementContext hotReplacementContext, + String rootPath) { this.password = password; this.next = next; this.hotReplacementContext = hotReplacementContext; + this.rootPath = rootPath; } public static void doPreScan() { @@ -98,11 +101,11 @@ private void handleRequest(HttpServerRequest event) { } else if (event.method().equals(HttpMethod.DELETE)) { handleDelete(event); } else if (event.method().equals(HttpMethod.POST)) { - if (event.path().equals(DEV)) { + if (event.path().endsWith(DEV)) { handleDev(event); - } else if (event.path().equals(CONNECT)) { + } else if (event.path().endsWith(CONNECT)) { handleConnect(event); - } else if (event.path().equals(PROBE)) { + } else if (event.path().endsWith(PROBE)) { event.response().end(); } else { event.response().putHeader(QUARKUS_ERROR, "Unknown path " + event.path() @@ -220,7 +223,8 @@ public void handle(Buffer buffer) { return; } try { - hotReplacementContext.updateFile(event.path(), buffer.getBytes()); + String path = stripRootPath(event.path()); + hotReplacementContext.updateFile(path, buffer.getBytes()); } catch (Exception e) { log.error("Failed to update file", e); } @@ -236,6 +240,12 @@ public void handle(Throwable error) { }).resume(); } + private String stripRootPath(String path) { + return path.startsWith(rootPath) + ? path.substring(rootPath.length()) + : path; + } + private void handleDelete(HttpServerRequest event) { if (checkSession(event, event.path().getBytes(StandardCharsets.UTF_8))) return;