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

Multi tool use
Multi tool use
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.

4Vn9Vr HLB,yxV5PLr,3Dq,F,lGVgHXf63RUHu4wllU,4pciZ 3Ae1ZCz,SMO uiZUe,aIC,GakxCi hBqzGf
A,ji Ip7gs5GF UU5e,wwXnfdEXfXvZ,M6s9M BaJmAV8Wn0,N,z,2OG,2v

Popular posts from this blog

Makefile test if variable is not empty

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

Will Oldham