Modify curl setopt wrapper
This commit is contained in:
parent
614e53dbe0
commit
dc12c6b6e0
3 changed files with 8 additions and 8 deletions
|
@ -67,9 +67,9 @@ pub fn setopt_raw(
|
||||||
pub fn setopt(
|
pub fn setopt(
|
||||||
self: *@This(),
|
self: *@This(),
|
||||||
option: Option,
|
option: Option,
|
||||||
args: anytype,
|
arg: anytype,
|
||||||
) c_api.CURLcode {
|
) c_api.CURLcode {
|
||||||
return self.setopt_raw(@intFromEnum(option), args);
|
return self.setopt_raw(@intFromEnum(option), .{ arg });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const Utils = struct {
|
pub const Utils = struct {
|
||||||
|
|
|
@ -59,12 +59,12 @@ fn fetchThread(state: *AppState) !void {
|
||||||
|
|
||||||
const url = try std.fmt.allocPrintZ(allocator, "{}", .{departures_uri});
|
const url = try std.fmt.allocPrintZ(allocator, "{}", .{departures_uri});
|
||||||
defer allocator.free(url);
|
defer allocator.free(url);
|
||||||
_ = curl.setopt(.url, .{url.ptr});
|
_ = curl.setopt(.url, url.ptr);
|
||||||
|
|
||||||
var result = std.ArrayList(u8).init(allocator);
|
var result = std.ArrayList(u8).init(allocator);
|
||||||
defer result.deinit();
|
defer result.deinit();
|
||||||
_ = curl.setopt(.write_function, .{Curl.Utils.array_list_append});
|
_ = curl.setopt(.write_function, Curl.Utils.array_list_append);
|
||||||
_ = curl.setopt(.write_data, .{&result});
|
_ = curl.setopt(.write_data, &result);
|
||||||
|
|
||||||
const code = curl.perform();
|
const code = curl.perform();
|
||||||
std.debug.print("[departure/fetchThread] cURL Code: {}\n", .{code});
|
std.debug.print("[departure/fetchThread] cURL Code: {}\n", .{code});
|
||||||
|
|
|
@ -38,12 +38,12 @@ fn fetchThread(state: *AppState) !void {
|
||||||
|
|
||||||
const url = try std.fmt.allocPrintZ(allocator, "{}", .{locations_uri});
|
const url = try std.fmt.allocPrintZ(allocator, "{}", .{locations_uri});
|
||||||
defer allocator.free(url);
|
defer allocator.free(url);
|
||||||
_ = curl.setopt(.url, .{url.ptr});
|
_ = curl.setopt(.url, url.ptr);
|
||||||
|
|
||||||
var result = std.ArrayList(u8).init(allocator);
|
var result = std.ArrayList(u8).init(allocator);
|
||||||
defer result.deinit();
|
defer result.deinit();
|
||||||
_ = curl.setopt(.write_function, .{Curl.Utils.array_list_append});
|
_ = curl.setopt(.write_function, Curl.Utils.array_list_append);
|
||||||
_ = curl.setopt(.write_data, .{&result});
|
_ = curl.setopt(.write_data, &result);
|
||||||
|
|
||||||
const code = curl.perform();
|
const code = curl.perform();
|
||||||
std.debug.print("[home/fetchThread] cURL Code: {}\n", .{code});
|
std.debug.print("[home/fetchThread] cURL Code: {}\n", .{code});
|
||||||
|
|
Loading…
Add table
Reference in a new issue