API 未处理端点的剩余响应代码
API rest response code for not handle endpoint
我有
/rest/drink/categories?alcohol=true
这是 return 200 状态代码,其中包含含有酒精的饮料类别列表,例如
200 ['wine','beer']
我想知道如果用户点击 none 处理的路径,我应该使用什么状态代码,如下所示
/rest/drink
或
/rest/drink?alcohol=true
404 - Not found 如果 URL 不存在,
400 - Bad request如果URL存在但请求参数无效
Http 具有此类条件的状态。
4XX
定义错误来自客户端,需要更改。
Wiki 说
The 4xx class of status code is intended for situations in which the client seems to have erred. Except when responding to a HEAD request, the server should include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents should display any included entity to the user.[31]
提到的条件,最好用404 - Not Found
或者400 - Bad Request
This 给出了所有状态代码的列表和适当的解释。
W3Org
定义了这些规范。
我有
/rest/drink/categories?alcohol=true
这是 return 200 状态代码,其中包含含有酒精的饮料类别列表,例如
200 ['wine','beer']
我想知道如果用户点击 none 处理的路径,我应该使用什么状态代码,如下所示
/rest/drink
或
/rest/drink?alcohol=true
404 - Not found 如果 URL 不存在,
400 - Bad request如果URL存在但请求参数无效
Http 具有此类条件的状态。
4XX
定义错误来自客户端,需要更改。
Wiki 说
The 4xx class of status code is intended for situations in which the client seems to have erred. Except when responding to a HEAD request, the server should include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents should display any included entity to the user.[31]
提到的条件,最好用404 - Not Found
或者400 - Bad Request
This 给出了所有状态代码的列表和适当的解释。
W3Org 定义了这些规范。