ZF2 和 Apigility - 设置 GET 和 POST RPC 服务的正确方法
ZF2 & Apigility - Correct way to setup GET and POST RPC services
在 ApiGility 中设置 GET 和 POST 服务的正确方法是什么?
目前,如果我正在设置 GET 服务,我将在我的路由中包含我需要的变量:
/api/verify/merchant[/:merchant_code]
如果我想设置 POST 服务,我的路线会变成:
/api/verify/merchant
And I add a merchant_code 'field'
如果我想让我的路线同时接受POST和GET,我会这样做:
/api/verify/merchant[/:merchant_code]
and add a merchant_code field as well...
这是为此设置路由的正确方法吗?
一般来说,您 POST
收集端点上的新实体,因此在您的情况下 /api/verify/merchant
。服务器将响应一个新资源,其中包含新创建的 Merchant
的 self href。此 href 的格式类似于 /api/verify/merchant[/merchant_code]
,其中 merchant_code
将是新添加的 Merchant
资源的标识符。
向 /api/verify/merchant[/merchant_code]
发送 POST
请求不是 necessary/valid。根据您要执行的操作(读取、更新、删除、替换),您在商家资源的端点上执行 GET
、PATCH
、DELETE
或 PUT
请求.
在 ApiGility 中设置 GET 和 POST 服务的正确方法是什么?
目前,如果我正在设置 GET 服务,我将在我的路由中包含我需要的变量:
/api/verify/merchant[/:merchant_code]
如果我想设置 POST 服务,我的路线会变成:
/api/verify/merchant
And I add a merchant_code 'field'
如果我想让我的路线同时接受POST和GET,我会这样做:
/api/verify/merchant[/:merchant_code]
and add a merchant_code field as well...
这是为此设置路由的正确方法吗?
一般来说,您 POST
收集端点上的新实体,因此在您的情况下 /api/verify/merchant
。服务器将响应一个新资源,其中包含新创建的 Merchant
的 self href。此 href 的格式类似于 /api/verify/merchant[/merchant_code]
,其中 merchant_code
将是新添加的 Merchant
资源的标识符。
向 /api/verify/merchant[/merchant_code]
发送 POST
请求不是 necessary/valid。根据您要执行的操作(读取、更新、删除、替换),您在商家资源的端点上执行 GET
、PATCH
、DELETE
或 PUT
请求.