-
Notifications
You must be signed in to change notification settings - Fork 477
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
ControllerLinkBuilder.linkTo is not working for actuator @Endpoint #674
Comments
I guess we need @wilkinsona's advice here. I'm afraid we can't do much about that as Spring HATEOAS doesn't and must not know anything about Spring Boot specifics. The only thing I can imagine is an |
I've found temporary workaround using
I also found the following ticket: |
An endpoint, even a web-specific one, that's trying to do something that's Spring MVC-specific doesn't feel right to me. The endpoint contract in Spring Boot 2.0 has been deliberately tightened up to allow us to expose endpoints using Jersey, Spring MVC, or WebFlux in addition to JMX. We can, perhaps, look at providing an API for web-specific Actuator endpoints that lets you build links, or at least gives you access to the current path. Spring HATEOAS isn't the right tool for the job, though, as it's coupled to Spring's If your endpoint doesn't need the flexibility of being exposable using Jersey, WebFlux, or Spring MVC, you could turn it into a regular Spring MVC controller and continue to use your current approach. |
I would like to have simple controller registered on management port. Previously I was using |
@Aloren you can register your controller in the management context, please see the documentation. Note that the doc isn't as obvious as the 1.5.x version but we intend to work on that. We've discussed this use case on the team call yesterday and reinstating I guess there's not much we can do here so if that doesn't work, please raise an issue in the Spring Boot tracker. Thanks! |
Thank you for the answers. |
We are currently in the process of migrating from Spring Boot 1.5 to 2.0. We were previously using actuator's class
MvcEndpoint
with@RequestMapping
. Now new annotation for actuator endpoints was introduced:@Endpoint
. The following code was producing valid hateoas links in Spring Boot 1.5:The same code migrated to Spring Boot 2.0:
Actual result in Spring Boot 1.5:
"href":"http://localhost:9999/dashboards/dashboard2.json"
Actual result in in Spring Boot 2.0:
"href":"http://localhost:9999/dashboard2.json"
Expected result in Spring Boot 2.0:
"href":"http://localhost:9999/application/dashboards/dashboard2.json"
As I understand the issue is within
ControllerLinkBuilder
:It only knows about
@RequestMapping
and knows nothing about new@Endpoint
.Could you please advise what is the correct way in Spring Boot Actuator 2.0 to produce links with valid base path?
The text was updated successfully, but these errors were encountered: