Java 如何获取Restheart系列的Etag

Java 如何获取Restheart系列的Etag,java,mongodb,restheart,Java,Mongodb,Restheart,我正在尝试使用Restheart API删除一个集合 $http DELETE 127.0.0.1:8080/testDB/testCollection获取etag只需获取127.0.0.1:8080/testDB/testCollection?pagesize=0,您将在etag响应头的属性和之间找到它 http -a a:a 127.0.0.1:8080/db/coll?pagesize=0 HTTP/1.1 200 OK ... ETag: 58653f6b2d174c09c590262

我正在尝试使用Restheart API删除一个集合


$http DELETE 127.0.0.1:8080/testDB/testCollection
获取etag只需
获取127.0.0.1:8080/testDB/testCollection?pagesize=0
,您将在etag响应头的属性之间找到它

http -a a:a 127.0.0.1:8080/db/coll?pagesize=0
HTTP/1.1 200 OK
...
ETag: 58653f6b2d174c09c590262a**

{
    "_embedded": [], 
    "_etag": {
        "$oid": "58653f6b2d174c09c590262a"
    }, 
    "_id": "coll", 
    "_returned": 0,
}
还要注意,如果发生冲突,尝试删除集合将返回Etag响应头

http -a a:a DELETE 127.0.0.1:8080/db/coll
HTTP/1.1 409 Conflict
...
ETag: 58653f6b2d174c09c590262a

{
    "http status code": 409, 
    "http status description": "Conflict", 
    "message": "The collection's ETag must be provided using the 'If-Match' header."
}
最后,您可以在配置文件中设置Etag检查行为。默认情况下,仅在DELETE/db和/coll上检查etag,但可以对任何写入请求启用etag(例如,为了避免所谓的ghost写入问题)

从conf文件:

#### ETag policy

# the following configuration defines the default etag check policy
# the policy applies for dbs, collections (also applies to file buckets) and documents
# valid values are REQUIRED, REQUIRED_FOR_DELETE, OPTIONAL

etag-check-policy:
    db: REQUIRED_FOR_DELETE
    coll: REQUIRED_FOR_DELETE
    doc: OPTIONAL