PHP REST API 中的选项 [英] OPTIONS in PHP REST API

查看:38
本文介绍了PHP REST API 中的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 PHP 编写 REST API,但找不到任何解释如何使用 OPTIONS 的资源.它似乎是 REST API 的一个重要部分,这就是我发现的内容.

I'm writing a REST API in PHP and I can't find any resources explaining how to work with OPTIONS. It seems to be an important part of REST API's, that's about how much I've found.

谁能解释一下 OPTIONS 应该包含什么以及它应该如何格式化?

Can anyone explain what OPTIONS should contain and how it should be formatted?

提前致谢.

推荐答案

HTTP OPTIONS 方法返回(至少)服务器支持特定 URL 的 HTTP 方法.例如,如果您有一个资源 (/user),您可以在其中创建、检索和检索标头(但不能删除或更新),则 OPTIONS 应返回以下响应标头:

The HTTP OPTIONS method returns (at least) the HTTP methods that the server supports for a specific URL. Per example, if you have a resource (/user) where you can create, retrieve and retrieve headers (but not delete or update), OPTIONS should return the following response header:

Allow: GET,HEAD,POST

如果你也可以删除资源,那就是:

If you can delete the resource as well, it would be:

Allow: GET,HEAD,POST,DELETE

你懂的.

这篇关于PHP REST API 中的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆