简体   繁体   English

PHP REST API 中的选项

[英]OPTIONS in PHP REST API

I'm writing a REST API in PHP and I can't find any resources explaining how to work with OPTIONS.我正在用 PHP 编写 REST API,但找不到任何解释如何使用 OPTIONS 的资源。 It seems to be an important part of REST API's, that's about how much I've found.它似乎是 REST API 的重要组成部分,这就是我发现的内容。

Can anyone explain what OPTIONS should contain and how it should be formatted?谁能解释一下 OPTIONS 应该包含什么以及它应该如何格式化?

Thanks in advance.提前致谢。

The HTTP OPTIONS method returns (at least) the HTTP methods that the server supports for a specific URL. HTTP OPTIONS 方法返回(至少)服务器支持特定 URL 的 HTTP 方法。 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:例如,如果您有一个资源 ( /user ),您可以在其中创建、检索和检索标头(但不能删除或更新),则 OPTIONS 应返回以下响应标头:

Allow: GET,HEAD,POST

If you can delete the resource as well, it would be:如果您也可以删除资源,它将是:

Allow: GET,HEAD,POST,DELETE

You get the idea.你明白了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM