Execute HTTP request matching given path and yield JSON result object. Depending on type it could be:
- HttpType.VIEW
The client should setup view_complete callback in order to fetch
the result. Also he can setup view_data callback to fetch response
body in chunks as soon as possible, it will be called each time the
library receive a data chunk from socket. The empty <tt>bytes</tt>
argument (NULL pointer and zero size) is the sign of end of
response. Chunked callback allows to save memory on large datasets.
- HttpType.MANAGEMENT
Management requests allow you to configure the cluster, add/remove
buckets, rebalance etc. The result will be passed to management
callbacks (data/complete).
Example: Fetch first 10 docs from '_design/test/_view/all' view
HttpRequest req = HttpRequest();
HttpCommand cmd = HttpCommand() {
path = "_design/test/_view/all?limit=10",
body = null,
method = HttpMethod.GET,
chunked = 1,
content_type = "application/json"
};
StatusResponse response = instance.make_http_request(
null, HttpType.VIEW, &cmd, &req
);
Example: The same as above but with POST filter HttpRequest req = HttpRequest();
HttpCommand cmd = HttpCommand() {
path = "_design/test/_view/all?limit=10".data,
body = """{"keys": ["test_1000", "test_10002"]}""".data,
method = HttpMethod.POST,
chunked = 0,
content_type = "application/json"
};
StatusResponse response = instance.make_http_request(
null, HttpType.VIEW, ref cmd, ref req
);
Example: Delete bucket via REST management API
HttpRequest req = HttpRequest();
HttpCommand cmd = HttpCommand() {
path = query.data,
body = null,
method = HttpMethod.DELETE,
chunked = 0,
content_type = "application/x-www-form-urlencoded"
};
StatusResponse response = instance.make_http_request(
null, HttpType.MANAGEMENT, ref cmd, ref req
);
command_cookie |
A cookie passed to all of the notifications from this command |
type |
The type of the request needed. |
command |
The struct describing the command options |
request |
Where to store request handle |