Burninghering's Blog
article thumbnail
Published 2022. 4. 19. 20:18
Spring Boot REST API_DELETE Method Spring

  • 멱등성 : 몇번의 요청을 해도 같은 대답이 돌아오는가?
  • DataBody : DataBody에 data를 실어서 보내기 때문에 굳이 QueryParameter로 데이터를 보낼 필요는 없다.
  • 생성된 것을 조회하기 때문에 굳이 QueryParameter를 사용하지 않는다.

삭제되었던 데이터든, 현재 있는 데이터든 삭제되기 때문에 멱등성이 있다.

삭제되기 때문에 안정성은 없다.

보통 index 번호로 삭제하기 때문에, Data body는 가지지 않는다.


package com.example.delete.controller;

import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class DeleteApiController {

    @DeleteMapping("/delete/{userId}")
    public void delete(@PathVariable String userId, @RequestParam String account){

        System.out.println(userId);
        System.out.println(account);

        //delete -> 리소스 삭제 -> 무조건 200 (어쨌든 삭제했고, 삭제되어있기 때문에!)
    }
}

 

Delete API는 "리소스 삭제"이므로

무조건 서버 응답으로 200이 돌아온다.

어쨌든 삭제할 것이고, 삭제되어있는 것을 삭제하기 때문에 

 

'Spring' 카테고리의 다른 글

Object Mapper  (0) 2022.04.23
Response 내려주는 방법  (0) 2022.04.19
Spring Boot REST API_PUT Method  (0) 2022.04.18
Spring Boot REST API_POST Method  (0) 2022.04.12
Spring Boot REST API_Get Method  (0) 2022.03.22
profile

Burninghering's Blog

@개발자 김혜린

안녕하세요! 반갑습니다.