Spring Rest Api Design For Following a User in Twitter Clone Appliction?

Multi tool use


Spring Rest Api Design For Following a User in Twitter Clone Appliction?
i Want to Design a Demo Twitter Clone Application where user can follow any other user . however i am doubting my rest api design . please suggest me am i right . can we pass followerId in url rather than passing it as requestbody ?
and if better option could be there like put/patch or any rest api design ?
Here JwtUser is Authenticated User
public class FollowerDto {
@NotBlank
private Long followerId;
private boolean following;
public FollowerDto() {
}
public FollowerDto(Long followerId, boolean following) {
this.followerId = followerId;
this.following = following;
}
public boolean getFollowing() {
return following;
}
public void setFollowing(boolean following) {
this.following = following;
}
public Long getFollowerId() {
return followerId;
}
public void setFollowerId(Long followerId) {
this.followerId = followerId;
}
}
@PostMapping("/follower")
@ResponseStatus(HttpStatus.CREATED)
public StatusDto addFollower(@RequestBody @Valid final FollowerDto
followerDto, @CurrentUser final JwtUser user, final
HttpServletResponse response) {
RestPreconditions.checkRequestElementNotNull(followerDto);
RestPreconditions.checkArgumentCondition(followerDto.getFollowing());
return userService.addFollower(user, followerDto.getFollowerId(),
response);
}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.