Last active
November 21, 2023 17:02
-
-
Save milanov/8a8fcabde51f31da0bfb to your computer and use it in GitHub Desktop.
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
private static final MappingDiscoverer DISCOVERER = new AnnotationMappingDiscoverer(RequestMapping.class); | |
public static URI linkTo(Object invocationValue) { | |
LastInvocationAware invocations = (LastInvocationAware) invocationValue; | |
DummyInvocationUtils.MethodInvocation invocation = invocations.getLastInvocation(); | |
String mapping = DISCOVERER.getMapping(invocation.getTargetType(), invocation.getMethod()); | |
return new UriTemplate(mapping).expand(invocation.getArguments()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am relatively new to Java and Spring-boot. How do you make it work with spring boot? Did you create a new file with this code in the codebase or add this static method? I can change the other URLs from absolute to relative but not the pagination URLs since PagedResourcesAssembler generates those.