Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloudef committed Dec 21, 2023
1 parent b5529a8 commit 5a70def
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ This package is in its early stage, although the core functionality works right

* Usage
#+begin_src zig
const Easy = @import("curl").Easy;
const curl = @import("curl");

pub fn main() !void {
try curl.global_init();
defer curl.global_deinit();

// Use zig's std.crypto.Certificate.Bundle
// Required if using builtin libcurl if TLS connections are required
try curl.refresh_ca_bundle();

var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();

const easy = try Easy.init(allocator);
const easy = try curl.Easy.init(allocator);
defer easy.deinit();

const resp = try easy.get("http://httpbin.org/anything");
Expand Down Expand Up @@ -66,8 +73,9 @@ const curl = b.dependency("curl", .{});

// add curl module to an executable.
exe.addModule("curl", curl.module("curl"));
// Note: since this package doesn't bundle static libcurl,
// so users need to link to system-wide libcurl.
// For builtin libcurl
exe.linkLibrary(curl.artifact("curl"));
// For system-wide libcurl
exe.linkSystemLibrary("curl");
exe.linkLibC();
#+end_src
Expand Down

0 comments on commit 5a70def

Please sign in to comment.