1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 23:24:09 +00:00

Update to new zig master api changes

This commit is contained in:
Ed Yu 2023-10-24 15:09:40 -07:00
parent c5d86376f8
commit 79fb534e80
5 changed files with 10 additions and 10 deletions

View file

@ -11,11 +11,11 @@ fn makeRequest(a: std.mem.Allocator, url: []const u8) !void {
var http_client: std.http.Client = .{ .allocator = a };
defer http_client.deinit();
var req = try http_client.request(.GET, uri, h, .{});
var req = try http_client.open(.GET, uri, h, .{});
defer req.deinit();
try req.headers.append("cookie", "ZIG_ZAP=awesome");
try req.start(.{});
try req.send(.{});
try req.wait();
}

View file

@ -11,10 +11,10 @@ fn makeRequest(a: std.mem.Allocator, url: []const u8) !void {
var http_client: std.http.Client = .{ .allocator = a };
defer http_client.deinit();
var req = try http_client.request(.GET, uri, h, .{});
var req = try http_client.open(.GET, uri, h, .{});
defer req.deinit();
try req.start(.{});
try req.send(.{});
try req.wait();
}

View file

@ -88,7 +88,7 @@ fn get_tag_annotation(allocator: std.mem.Allocator, tagname: []const u8) ![]cons
tagname,
};
const result = try std.ChildProcess.exec(.{
const result = try std.ChildProcess.run(.{
.allocator = allocator,
.argv = &args,
});
@ -161,13 +161,13 @@ fn sendToDiscordPart(allocator: std.mem.Allocator, url: []const u8, message_json
defer http_client.deinit();
// request
var req = try http_client.request(.POST, uri, h, .{});
var req = try http_client.open(.POST, uri, h, .{});
defer req.deinit();
req.transfer_encoding = .chunked;
// connect, send request
try req.start(.{});
try req.send(.{});
// send POST payload
try req.writer().writeAll(message_json);

View file

@ -71,7 +71,7 @@ pub const usage_pkg =
;
pub fn gitLatestTag(gpa: Allocator, pkg_dir: []const u8) ![]const u8 {
const result = try std.ChildProcess.exec(.{
const result = try std.ChildProcess.run(.{
.allocator = gpa,
.argv = &.{
"git",
@ -97,7 +97,7 @@ pub fn gitLatestTag(gpa: Allocator, pkg_dir: []const u8) ![]const u8 {
}
pub fn gitFileList(gpa: Allocator, pkg_dir: []const u8) ![]const u8 {
const result = try std.ChildProcess.exec(.{
const result = try std.ChildProcess.run(.{
.allocator = gpa,
.argv = &.{
"git",

View file

@ -30,7 +30,7 @@ pub fn main() !void {
res.transfer_encoding = .{ .content_length = server_body.len };
try res.headers.append("content-type", "text/plain");
try res.headers.append("connection", "close");
try res.do();
try res.send();
var buf: [128]u8 = undefined;
_ = try res.readAll(&buf);