micronaut-core
micronaut-core copied to clipboard
Discovery of management endpoints
Solves #5006
Created the endpoint /management to reveal mangament routes in a HATEOAS format. This is the format that Spring Boot's /actuator uses. Example output:
{
"_links": {
"self": {
"href": "http://localhost:8080/management",
"templated": false
},
"threaddump": {
"href": "http://localhost:8080/threaddump",
"templated": false
},
"loggers": [
{
"href": "http://localhost:8080/loggers/{name}",
"templated": true
},
{
"href": "http://localhost:8080/loggers",
"templated": false
}
]
}
Considerations:
- Duplicate route paths are not shown because the output does not provide HTTP method information to differentiate them. For example, if a route accepts GET and HEAD, a single path is shown (not one per method).
- Regardless of the HTTP method of the route, it is shown if it is a management endpoint. This means that to use some links it is not enough to click on them. I allowed this to keep the design similar to Spring Boot Actuator, since at
/actuatorit can show/actuator/shutdownwhich expects a POST, not a GET. - The implementation also shows custom endpoints defined by the user.
Work that I think is pending
- [x] Implement tests for
ManagementController
Thinking about this more it seems like it would be better done with a controller if the goal is to discover the HTTP links
Thinking about this more it seems like it would be better done with a controller if the goal is to discover the HTTP links
@jameskleeh By using a controller, would an EmbeddedServer injected in the controller return the correct scheme, host and port to create the links? I think that having clickable links as the author of the issue mentions would be helpful for navigation
Thinking about this more it seems like it would be better done with a controller if the goal is to discover the HTTP links
@jameskleeh By using a controller, would an
EmbeddedServerinjected in the controller return the correct scheme, host and port to create the links? I think that having clickable links as the author of the issue mentions would be helpful for navigation
No you would have to inject the HttpHostResolver
@jameskleeh I've addressed your suggestions, now I'm also targeting branch 3.0.x
@jameskleeh I've implemented the tests for the management controller.
Locally ./gradlew check passes all tests
Hi @jameskleeh, are there additional changes that I should make?
@HerCerM Overall it looks OK however we are hard at work getting the next milestone of 3.0 out so we'll get this merged afterwards
Hi @graemerocher, thanks for the review and sorry for the delay. I expect to address the changes during the next week, since currently I have other things at hand
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.