【发布时间】:2017-06-22 12:09:21
【问题描述】:
我已经阅读 REST 一周了,我能说的一切都可以在 1 分钟内学会,我可以使用 HTTP 请求,例如 GET/POST/PUT/DELETE 操纵网站内容
但是当人们描述 REST 时,什么是无状态和其他难以理解的术语?
为什么我不能通过$_GET[''] 这样的http://localhost/register.php?id=1&username=bob 方法将内容添加到数据库中,这里我使用了所谓的$_GET[] 方法 - 我相信这与 REST(GET/ PUT) 方法 - 并将信息插入到数据库中,而不是使用相同的方法,只是以更复杂的方式理解
【问题讨论】:
-
Wikipedia 实际上总结得很好:
The client–server communication is constrained by no client context being stored on the server between requests. Each request from any client contains all the information necessary to service the request, and session state is held in the client.示例:您不只是验证自己一次,然后执行您想要的所有 API 请求,而是在每个请求中验证自己。例如请求中的某个标记或资源 uri 本身。