forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring back the HTTP console commands
These were erroneously removed in 19aae16
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...p/deployment/src/main/java/io/quarkus/vertx/http/deployment/console/ConsoleProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.quarkus.vertx.http.deployment.console; | ||
|
||
import static io.quarkus.devui.deployment.ide.IdeProcessor.openBrowser; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
import org.eclipse.microprofile.config.ConfigProvider; | ||
|
||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.Produce; | ||
import io.quarkus.deployment.builditem.LaunchModeBuildItem; | ||
import io.quarkus.deployment.builditem.ServiceStartBuildItem; | ||
import io.quarkus.deployment.console.ConsoleCommand; | ||
import io.quarkus.deployment.console.ConsoleStateManager; | ||
import io.quarkus.dev.spi.DevModeType; | ||
import io.quarkus.vertx.http.deployment.HttpRootPathBuildItem; | ||
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem; | ||
|
||
public class ConsoleProcessor { | ||
|
||
static volatile ConsoleStateManager.ConsoleContext context; | ||
|
||
@Produce(ServiceStartBuildItem.class) | ||
@BuildStep | ||
void setupConsole(HttpRootPathBuildItem rp, NonApplicationRootPathBuildItem np, LaunchModeBuildItem launchModeBuildItem) { | ||
if (launchModeBuildItem.getDevModeType().orElse(null) != DevModeType.LOCAL) { | ||
return; | ||
} | ||
if (context == null) { | ||
context = ConsoleStateManager.INSTANCE.createContext("HTTP"); | ||
} | ||
Config c = ConfigProvider.getConfig(); | ||
String host = c.getOptionalValue("quarkus.http.host", String.class).orElse("localhost"); | ||
String port = c.getOptionalValue("quarkus.http.port", String.class).orElse("8080"); | ||
context.reset( | ||
new ConsoleCommand('w', "Open the application in a browser", null, () -> openBrowser(rp, np, "/", host, port)), | ||
new ConsoleCommand('d', "Open the Dev UI in a browser", null, | ||
() -> openBrowser(rp, np, "/q/dev-ui", host, port))); | ||
} | ||
} |