首页 > 解决方案 > 如果电子邮件(或其他)存在,我应该返回哪个 HTTP 响应?

问题描述

在 symfony api REST 中,

现在我这样做:

//mail exist:
$this->json("", Response::HTTP_OK) //200

//mail does not exist:
$this->json("", Response::HTTP_BAD_REQUEST) //400

但我想知道这样做是否更好:

$this->json("email exist", Response::HTTP_OK) //200
$this->json("email does not exist", Response::HTTP_OK) //200

标签: apirestsymfony

解决方案


相应的响应代码应该是 409 Conflict


推荐阅读