带有 GET 的 couchdb 更新处理程序
couchdb update handler with GET
我正在尝试使用 CouchDB 与一些第三方服务集成。我一直在使用更新处理程序,因此我可以记录对数据库的响应。
不幸的是,在一种情况下,我可以指定 return URL,但我不能指定 method
,方法总是 GET
。
{
error: "method_not_allowed",
reason: "Update functions do not allow GET"
}
有人知道解决方法吗?我可以使用另一个处理程序吗? None 其他人似乎允许编写文档。
我读过这个
https://lbl.io/post/url-shortening-with-couchdb
我希望避免创建代理,并且我使用的是托管服务 (smileupps),所以没有自定义。
假设是通过浏览器传递,可以使用一些javascript和html。这不处理任何(例如)使用 non-javascript/html 支持客户端
的情况
设置您的 rewrites
{
"from": "/endpoint",
"to": "proxy.html",
"method": "GET",
"query": {}
},
{
"from": "/endpoint",
"to": "_update/endpoint",
"method": "*",
"query": {}
}
proxy.html
<html>
<body>
<form method='POST'></form>
<script>
var form = document.getElementsByTagName("form")[0];
form.setAttribute("action", window.location);
form.submit();
</script>
</body>
</html>
通知被发送到 endpoint
,然后再发送到代理。代理使用完全相同的 URL 和 POST
生成一个表单。 post 版本被重写为更新处理程序。
我正在尝试使用 CouchDB 与一些第三方服务集成。我一直在使用更新处理程序,因此我可以记录对数据库的响应。
不幸的是,在一种情况下,我可以指定 return URL,但我不能指定 method
,方法总是 GET
。
{
error: "method_not_allowed",
reason: "Update functions do not allow GET"
}
有人知道解决方法吗?我可以使用另一个处理程序吗? None 其他人似乎允许编写文档。
我读过这个
https://lbl.io/post/url-shortening-with-couchdb
我希望避免创建代理,并且我使用的是托管服务 (smileupps),所以没有自定义。
假设是通过浏览器传递,可以使用一些javascript和html。这不处理任何(例如)使用 non-javascript/html 支持客户端
的情况设置您的 rewrites
{
"from": "/endpoint",
"to": "proxy.html",
"method": "GET",
"query": {}
},
{
"from": "/endpoint",
"to": "_update/endpoint",
"method": "*",
"query": {}
}
proxy.html
<html>
<body>
<form method='POST'></form>
<script>
var form = document.getElementsByTagName("form")[0];
form.setAttribute("action", window.location);
form.submit();
</script>
</body>
</html>
通知被发送到 endpoint
,然后再发送到代理。代理使用完全相同的 URL 和 POST
生成一个表单。 post 版本被重写为更新处理程序。