11.4.3 删除资源

WebClient 还允许使用 delete() 方法删除资源。例如,下面的代码通过给定的 ID 删除 Ingredient 对象:

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

和 PUT 请求一样,DELETE 请求通常没有响应体。同样,返回并订阅 Mono 以发送请求。

results matching ""

    No results matching ""