-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32026 from cescoffier/management-interface-for-app
Allows applications to expose management endpoints
- Loading branch information
Showing
8 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/ManagementInterface.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,18 @@ | ||
package io.quarkus.vertx.http; | ||
|
||
import io.vertx.ext.web.Router; | ||
|
||
/** | ||
* A class allowing to access the management router. | ||
* You can access the instance of this class using a CDI observer: | ||
* {@code public void init(@Observe ManagementInterface mi) {...}} | ||
* <p> | ||
* If the management interface is disabled, the event is not fired. | ||
*/ | ||
public interface ManagementInterface { | ||
|
||
/** | ||
* @return the management router | ||
*/ | ||
Router router(); | ||
} |
18 changes: 18 additions & 0 deletions
18
...rtx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/ManagementInterfaceImpl.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,18 @@ | ||
package io.quarkus.vertx.http.runtime; | ||
|
||
import io.quarkus.vertx.http.ManagementInterface; | ||
import io.vertx.ext.web.Router; | ||
|
||
public class ManagementInterfaceImpl implements ManagementInterface { | ||
|
||
private final Router router; | ||
|
||
public ManagementInterfaceImpl(Router router) { | ||
this.router = router; | ||
} | ||
|
||
@Override | ||
public Router router() { | ||
return router; | ||
} | ||
} |
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
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
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
29 changes: 29 additions & 0 deletions
29
...ration-tests/vertx-http/src/main/java/io/quarkus/it/vertx/NoManagementInterfaceRoute.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,29 @@ | ||
package io.quarkus.it.vertx; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.event.Observes; | ||
|
||
import io.quarkus.vertx.http.ManagementInterface; | ||
import io.vertx.ext.web.Router; | ||
|
||
@ApplicationScoped | ||
public class NoManagementInterfaceRoute { | ||
|
||
boolean exposed; | ||
|
||
void initMain(@Observes Router router) { | ||
router.get("/management-interface-test").handler(rc -> { | ||
if (exposed) { | ||
rc.response().setStatusCode(500).end("KO"); | ||
} else { | ||
rc.response().end("OK"); | ||
} | ||
}); | ||
} | ||
|
||
void init(@Observes ManagementInterface mi) { | ||
exposed = true; | ||
mi.router().get("/admin").handler(rc -> rc.response().end("admin it is")); | ||
} | ||
|
||
} |
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