Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevUI: Info extension #32307

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.quarkus.info.deployment;

import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.devui.spi.page.CardPageBuildItem;
import io.quarkus.devui.spi.page.Page;
import io.quarkus.info.runtime.InfoRecorder;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.runtime.management.ManagementInterfaceBuildTimeConfig;

/**
* This processor is responsible for the dev ui widget.
*/
public class InfoDevUiProcessor {

@BuildStep(onlyIf = IsDevelopment.class)
@Record(ExecutionTime.STATIC_INIT)
CardPageBuildItem create(NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
InfoBuildTimeConfig config,
ManagementInterfaceBuildTimeConfig managementInterfaceBuildTimeConfig,
LaunchModeBuildItem launchModeBuildItem,
InfoRecorder unused) {
CardPageBuildItem pageBuildItem = new CardPageBuildItem();

var path = nonApplicationRootPathBuildItem.resolveManagementPath(config.path(),
managementInterfaceBuildTimeConfig, launchModeBuildItem);
pageBuildItem.addPage(Page.externalPageBuilder("App Information")
.icon("font-awesome-solid:circle-info")
.url(path)
.isJsonContent());
Copy link
Contributor

@gastaldi gastaldi Mar 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's too late for this, but shouldn't this method be named asJsonContent()? /cc @phillip-kruger

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that is giving the client a hint on what the content type is. If it's not set, the ui makes a header call to get the content type. So this is to bypass that header call if we know the type. See


return pageBuildItem;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.vertx.core.Handler;
import io.vertx.core.http.HttpHeaders;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.RoutingContext;

Expand Down Expand Up @@ -44,7 +45,7 @@ public void handle(RoutingContext ctx) {
HttpServerResponse resp = ctx.response();
resp.headers().set(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8");
JsonObject jsonObject = new JsonObject(finalBuildInfo);
ctx.json(jsonObject);
ctx.end(Json.encodePrettily(jsonObject));
}
}
}