-
Notifications
You must be signed in to change notification settings - Fork 474
Closed
Labels
Milestone
Description
I am looking to create a rel link for all controller endpoints I expose in my application in a generic way using Java Reflection. Not by individually referring the controller and its respective method by having a 'methodOn' reference of LinkBuilder. I tried the below for acheiving the same in my generic service.
`requestMappingHandlerMapping.getHandlerMethods().values().stream()
.map(HandlerMethod::getMethod)
.forEach(method -> {
Entry<String, String> index = retrieveKeyAnnotation(method); //Here we have a customized Key annotation on our controller class, Any Insights on resolving this issue could be much helpful and appreciated.
from which the the rel Key is formed.
if (index != null) { resourceSupport.addIfSecure(WebMvcLinkBuilder.linkTo(method,method.getParameters()).withRel(index.getKey()));
} //resourceSupport is an object of a class which inherits RepresentationModel.
});
`My controller class looks like this.
@Key(value="key", doc="Description")
@GetMapping("/endPoint")
public ResponseEntity<EntityModel<ModelClass>> trigger(@RequestParam String param){
}
Here the rel link is formed. But if there is a query parameter in my controller, that doesn't come in the rel link. Please find below the example.
Expected:
{
"_links": {
"curie-prefix:keyu": {
"href": "http://appName/contextPath/endPoint?param={param}",
},
"curies": [{
"href": "http://appName/contextPath/generated-docs/api-guide.html#resources-{rel}",
"name": "curie-prefix",
"templated": true
}]
}
}
Actual:
"_links": {
"curie-prefix:keyu": {
"href": "http://appName/contextPath/endPoint",
},
"curies": [{
"href": "http://appName/contextPath/generated-docs/api-guide.html#resources-{rel}",
"name": "curie-prefix",
"templated": true
}]
}
}
you can find the queryParam missing in the actual link. Here when I debug through the flow I find HierarchicalUriComponents didn't recognize the QueryParam due to a deadlock condition.