braheezy/ada-zig
Zig bindings for Ada URL library.
Ada is a fast and spec-compliant URL parser written in C++. Specification for URL parser can be found from the WHATWG website.
This project contains Zig language bindings. That means instead of linking the C library directly in your project and interacting with the C API, zig-ada
does it for you, providing a thin wrapper for familiar Zig use.
First, add to your build.zig.zon
:
zig fetch --save git+https://github.com/braheezy/ada-zig#2.9.2
Then update your build.zig
:
const ada_dep = b.dependency("ada-zig", .{});
exe.root_module.addImport("ada", ada_dep.module("ada"));
Finally, in your source code:
const ada = @import("ada");
pub fn main() void {
const ada_url = try ada.Url.init("https://ziglang.org/");
std.debug.print(ada_url.getProtocol());
// prints 'https'
}
The Usage docs from the Ada library are applicable.
const std = @import("std");
const ada = @import("ada");
pub fn main() !void {
const input_url = "https://user:[email protected]:8080/path?query=1#frag";
const url = try ada.Url.init(input_url);
defer url.free();
std.debug.print("url.host type: {any}\n", .{url.getHostType()});
}
See zig build --list
.