假设我的事实数据库至少填充了:
fact1(A) :- !, A=ok.
fact2(B) :- !, B=ok.
Run Code Online (Sandbox Code Playgroud)
如何枚举此数据库中的所有事实?理想情况下,我有一个可以使用的谓词:
?- all_rules( Head :- Tail).
Head=fact1(_G100),
Tail=(!, _G100=ok) ;
Head=fact2(_G101),
Tail=(!, _G101=ok)
....followed by all other predicates in other modules loaded...
Run Code Online (Sandbox Code Playgroud)
我发现current_predicate/1,但我无法弄清楚这实际上是做什么的......
我想通过使用proxy_pass在我的域上运行NGINX来暴露Cloudant的一些couchdb功能.到目前为止,我已经解决了一些问题(如下所述),但就授权而言,我陷入困境.有人有任何提示吗?
location /couchdb {
rewrite /couchdb/(.*) /$1 break; #chop off start of this url
proxy_redirect off
proxy_buffering off;
proxy_set_header Host myusername.cloudant.com;
# cannot use $host! must specify my vhost on cloudant
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Authorization "Basic base64-encode(username:password)";
proxy_pass http://myusername.cloudant.com$request_uri;
# must use a variable in this url so that the domain is looked up late.
# otherwise nginx will fail to start about half the time because of resolver issues
# (unknown why though)
}
Run Code Online (Sandbox Code Playgroud)
使用此设置,我可以成功代理Cloudant,但我总是收到禁止的响应.例如,这个请求:
http://mydomain/couchdb/my-cloudant-db
Run Code Online (Sandbox Code Playgroud)
回报
{"error":"forbidden", …
Run Code Online (Sandbox Code Playgroud)