Skip to content

Commit

Permalink
Merge pull request #46075 from gsmet/configmapping-cleanup
Browse files Browse the repository at this point in the history
Vert.x HTTP - Switch DevUIConfig to @ConfigMapping
  • Loading branch information
gsmet authored Feb 4, 2025
2 parents f6d54eb + 385e366 commit d656dc3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public boolean equals(Object obj) {
@Deprecated(forRemoval = true)
@JsonIgnore
public boolean isMixedModule() {
return "io.quarkus".equals(groupId) && ("quarkus-core".equals(artifactId) || "quarkus-vertx-http".equals(artifactId)
|| "quarkus-messaging".equals(artifactId));
return "io.quarkus".equals(groupId) && ("quarkus-core".equals(artifactId) || "quarkus-vertx-http".equals(artifactId));
}

@JsonIgnore
Expand Down
3 changes: 0 additions & 3 deletions extensions/vertx-http/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-AlegacyConfigRoot=true</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ private void addFooterTabBuildTimeData(BuildTimeConstBuildItem internalBuildTime
footerTabs.add(testLog);

// This is only needed when extension developers work on an extension, so we only included it if you build from source.
if (Version.getVersion().equalsIgnoreCase("999-SNAPSHOT") || devUIConfig.showJsonRpcLog) {
if (Version.getVersion().equalsIgnoreCase("999-SNAPSHOT") || devUIConfig.showJsonRpcLog()) {
Page devUiLog = Page.webComponentPageBuilder().internal()
.namespace("devui-jsonrpcstream")
.title("Dev UI")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@
import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;

@ConfigRoot(name = "dev-ui")
public class DevUIConfig {
@ConfigRoot
@ConfigMapping(prefix = "quarkus.dev-ui")
public interface DevUIConfig {

/**
* The number of history log entries to remember.
*/
@ConfigItem(defaultValue = "50")
public int historySize;
@WithDefault("50")
int historySize();

/**
* Show the JsonRPC Log. Useful for extension developers
*/
@ConfigItem(defaultValue = "false")
public boolean showJsonRpcLog;
@WithDefault("false")
boolean showJsonRpcLog();

/**
* More hosts allowed for Dev UI
Expand All @@ -29,22 +31,21 @@ public class DevUIConfig {
* (This can also be a regex)
* By default localhost and 127.0.0.1 will always be allowed
*/
@ConfigItem
public Optional<List<String>> hosts = Optional.empty();
Optional<List<String>> hosts();

/**
* CORS configuration.
*/
public Cors cors = new Cors();
Cors cors();

@ConfigGroup
public static class Cors {
interface Cors {

/**
* Enable CORS filter.
*/
@ConfigItem(defaultValue = "true")
public boolean enabled = true;
@WithDefault("true")
boolean enabled();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ void registerDevUiHandlers(

routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.orderedRoute(DEVUI + SLASH_ALL, -2 * FilterBuildItem.CORS)
.handler(recorder.createLocalHostOnlyFilter(devUIConfig.hosts.orElse(null)))
.handler(recorder.createLocalHostOnlyFilter(devUIConfig.hosts().orElse(null)))
.build());

if (devUIConfig.cors.enabled) {
if (devUIConfig.cors().enabled()) {
routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.orderedRoute(DEVUI + SLASH_ALL, -1 * FilterBuildItem.CORS)
.handler(new DevUICORSFilter())
Expand Down

0 comments on commit d656dc3

Please sign in to comment.