用于检查资源是否存在的 REST 标准 [英] REST standard for checking if resource exists

查看:46
本文介绍了用于检查资源是否存在的 REST 标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检查资源是否存在的 REST 方法是什么?假设您有一些名为 Project 的资源.我低估了其中一种方法:

What is the REST way to check if resource exists or not? Let say you have some resource called Project. By my understating one of this would be the way :

获取资源

GET /rest/projects/123

GET /rest/projects/someCriteria

GET /rest/projects/listOfIds

很简单,但是如果可用,则整个对象都会被检索,我们只想检查它是否存在.是否有更优雅的解决方案,也许使用 HEAD?

simple but this way the entire object is retrieved if available and we just want to check if it is there. Is there more elegant solution, maybe using HEAD?

推荐答案

REST 的方式是在您的特定架构中使用统一接口允许的任何内容.对于 HTTP,最佳匹配是 HEAD.如果您需要资源的简单存在之外的信息,请考虑OPTIONS.

The REST way is to use whatever the uniform interface allows in your specific architecture. For HTTP the best match is HEAD. If you need information beyond the simple existence of a resource, consider OPTIONS.

这篇关于用于检查资源是否存在的 REST 标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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