api - 如果电子邮件(或其他)存在,我应该返回哪个 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
解决方案
相应的响应代码应该是 409 Conflict
推荐阅读
- python - Read_Csv() 没有给出预期的输出,如果我更新了 csv 中的任何单元格
- javascript - 取消选择并选择事件
- node.js - Next.js 的内存问题
- javascript - 为什么我的 Ajax 无法将数据保存到数据库中?Laravel 与 Ajax
- sql - 从其他表列检索记录
- javascript - 空白屏幕 - Matter.js
- druid - Druid Concat String 和 Measure 聚合
- javascript - MongoDB如何按索引替换数组项
- c - 使用 ARM Neon 内在函数实现 64 位变量的乘法时面临的问题
- rest-assured - 使用 RestArrured 触发时 API 返回 text/html 而不是 JSON