I would like to combine HATEAOS links to methods on both Controller and Repository.
@RepositoryRestController
@ResponseBody
@ExposesResourceFor(Group.class)
@RequestMapping(value = "/api/v2/groups", produces = MediaTypes.HAL_JSON_VALUE)
public class GroupController {
@Resource
private GroupService groupService;
@RequestMapping(value = "/external", method = POST)
public @ResponseBody PersistentEntityResource saveExternalGroup(
@RequestBody Group newGroup,
PersistentEntityResourceAssembler assembler) {
return assembler.toResource(groupService.saveExternalGroup(newGroup));
}
}
Repository:
@RepositoryRestResource(excerptProjection = GroupSummary.class)
public interface GroupDao extends DefaultDao<Group, Long> {
@NotNull
List<Group> findByState(@Nullable GroupState state);
...other methods...
I would like to achieve to have possibility to go to /api/v2/groups and have there also link to /external. Currently, only links from repository are returned:
"_links": {
"first": {
"href": "http://localhost:8300/api/v2/groups?page=0&size=20"
},
"self": {
"href": "http://localhost:8300/api/v2/groups"
},
"next": {
"href": "http://localhost:8300/api/v2/groups?page=1&size=20"
},
"last": {
"href": "http://localhost:8300/api/v2/groups?page=1&size=20"
},
"profile": {
"href": "http://localhost:8300/api/v2/profile/groups"
},
"search": {
"href": "http://localhost:8300/api/v2/groups/search"
}
},
What should I implement to get there all as above plus something like this:
"external": {
"href": "http://localhost:8300/api/v2/groups/external"
}
Or is there problem with that "/external" is POST? If so, please comment and consider this question with "method=GET".