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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Regex - How to capture all iterations of a repeating pattern?