Skip to content

12.4.3 Xoá tài nguyên

WebClient cũng cho phép xoá tài nguyên thông qua phương thức delete(). Ví dụ, đoạn mã sau xoá một nguyên liệu (ingredient) theo ID đã cho:

java
Mono<Void> result = webClient
  .delete()
  .uri("/ingredients/{id}", ingredientId)
  .retrieve()
  .bodyToMono(Void.class);

result.subscribe();

Cũng giống như các yêu cầu PUT, các yêu cầu DELETE thường không có nội dung (payload). Một lần nữa, bạn trả về và đăng ký (subscribe) với một Mono<Void> để gửi yêu cầu.

Released under the MIT License.