我有一个 REST 数据服务,我希望允许用户使用 json、xml、csv 等不同格式的 HTTP PUT 创建新项目。我不确定如何最好地处理 url 中的格式规范:
PUT /ressource/ID/json
PUT /ressource/ID/xml
或者
PUT /ressource/ID?format=json
PUT /ressource/ID?format=xml
那么指定格式指示符的最佳方法是什么?
如果我使用查询参数指定格式并且想要PUT
执行此操作,我该如何使用 curl 执行此操作?
curl -T test/data.json -d "format=json" http://localhost:5000/resource/33
不起作用。
curl -T test/data.json http://localhost:5000/update?format=json
有效,但我宁愿让 curl 构建查询参数,而不是自己添加它们。