Skip to content

Commit 11b21df

Browse files
committed
polish readme
1 parent 17d93b0 commit 11b21df

4 files changed

Lines changed: 98 additions & 35 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ docgen_tmp/
1616
.vagrant
1717
Vagrantfile
1818
zig-linux*
19-
docs
2019
libroot*
2120
.DS_Store
2221
*.o

README.org

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#+TITLE: zig-curl
22
#+DATE: 2023-09-16T23:16:15+0800
3-
#+LASTMOD: 2025-10-02T10:13:24+0800
3+
#+LASTMOD: 2025-10-03T12:35:20+0800
44
#+OPTIONS: toc:nil num:nil
55
#+STARTUP: content
66

77
[[https://img.shields.io/badge/zig%20version-0.15.1-blue.svg]]
8-
[[https://img.shields.io/badge/zig%20version-master-blue.svg]]
98
[[https://github.com/jiacai2050/zig-curl/actions/workflows/CI.yml][https://github.com/jiacai2050/zig-curl/actions/workflows/CI.yml/badge.svg]]
109
[[https://ci.codeberg.org/repos/13257][https://ci.codeberg.org/api/badges/13257/status.svg]]
1110

1211
Zig bindings for [[https://curl.haxx.se/libcurl/][libcurl]], a free and easy-to-use client-side URL transfer library.
1312

13+
#+ATTR_HTML: :width 30%
14+
[[file:docs/logo.svg]]
15+
1416
The vendored libraries consist of:
1517
| Library | Version |
1618
|---------+---------|
@@ -26,11 +28,7 @@ cat examples/basic.zig
2628
#+RESULTS:
2729
#+begin_src zig
2830
const std = @import("std");
29-
const println = @import("util.zig").println;
30-
const mem = std.mem;
31-
const Allocator = mem.Allocator;
3231
const curl = @import("curl");
33-
const Easy = curl.Easy;
3432

3533
pub fn main() !void {
3634
var gpa: std.heap.DebugAllocator(.{}) = .init;
@@ -39,38 +37,35 @@ pub fn main() !void {
3937

4038
const ca_bundle = try curl.allocCABundle(allocator);
4139
defer ca_bundle.deinit();
42-
const easy = try Easy.init(.{
40+
const easy = try curl.Easy.init(.{
4341
.ca_bundle = ca_bundle,
4442
});
4543
defer easy.deinit();
44+
4645
{
47-
println("GET without write context");
46+
std.debug.print("GET without body\n", .{});
4847
const resp = try easy.fetch("https://httpbin.org/anything", .{});
49-
5048
std.debug.print("Status code: {d}\n", .{resp.status_code});
5149
}
5250

5351
{
54-
println("GET with fixed buffer");
52+
std.debug.print("\nGET with fixed buffer as body\n", .{});
5553
var buffer: [1024]u8 = undefined;
5654
var writer = std.Io.Writer.fixed(&buffer);
57-
const resp = try easy.fetch("https://httpbin.org/anything", .{
58-
.writer = &writer,
59-
});
60-
std.debug.print("Status code: {d}\nBody: {s}\n", .{
61-
resp.status_code,
62-
writer.buffered(),
63-
});
55+
const resp = try easy.fetch("https://httpbin.org/anything", .{ .writer = &writer });
56+
std.debug.print("Status code: {d}\nBody: {s}\n", .{ resp.status_code, writer.buffered() });
6457
}
6558
}
6659
#+end_src
6760

61+
Check [[file:examples]] for more examples.
6862

69-
See [[file:examples/basic.zig]], [[file:examples/advanced.zig]] for more usage.
63+
* Documentation
64+
See https://jiacai2050.github.io/zig-curl/
7065

7166
* Installation
7267
#+begin_src bash
73-
zig fetch --save=curl https://github.com/jiacai2050/zig-curl/archive/refs/tags/${TAG}.zip
68+
zig fetch --save=curl https://github.com/jiacai2050/zig-curl/archive/refs/tags/${TAG}.zip
7469
#+end_src
7570

7671
The latest tag can be found on [[https://github.com/jiacai2050/zig-curl/releases/][release page]].

docs/logo.svg

Lines changed: 78 additions & 0 deletions
Loading

examples/basic.zig

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
const std = @import("std");
2-
const println = @import("util.zig").println;
3-
const mem = std.mem;
4-
const Allocator = mem.Allocator;
52
const curl = @import("curl");
6-
const Easy = curl.Easy;
73

84
pub fn main() !void {
95
var gpa: std.heap.DebugAllocator(.{}) = .init;
@@ -12,27 +8,22 @@ pub fn main() !void {
128

139
const ca_bundle = try curl.allocCABundle(allocator);
1410
defer ca_bundle.deinit();
15-
const easy = try Easy.init(.{
11+
const easy = try curl.Easy.init(.{
1612
.ca_bundle = ca_bundle,
1713
});
1814
defer easy.deinit();
15+
1916
{
20-
println("GET without write context");
17+
std.debug.print("GET without body\n", .{});
2118
const resp = try easy.fetch("https://httpbin.org/anything", .{});
22-
2319
std.debug.print("Status code: {d}\n", .{resp.status_code});
2420
}
2521

2622
{
27-
println("GET with fixed buffer");
23+
std.debug.print("\nGET with fixed buffer as body\n", .{});
2824
var buffer: [1024]u8 = undefined;
2925
var writer = std.Io.Writer.fixed(&buffer);
30-
const resp = try easy.fetch("https://httpbin.org/anything", .{
31-
.writer = &writer,
32-
});
33-
std.debug.print("Status code: {d}\nBody: {s}\n", .{
34-
resp.status_code,
35-
writer.buffered(),
36-
});
26+
const resp = try easy.fetch("https://httpbin.org/anything", .{ .writer = &writer });
27+
std.debug.print("Status code: {d}\nBody: {s}\n", .{ resp.status_code, writer.buffered() });
3728
}
3829
}

0 commit comments

Comments
 (0)