Skip to content

braheezy/ada-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ada Zig

docs

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, adazig does it for you, providing a thin wrapper for familiar Zig use.

Usage

First, add to your build.zig.zon:

zig fetch --save git+https://github.com/braheezy/ada-zig#3.1.3

Then update your build.zig:

const ada_dep = b.dependency("adazig", .{});
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'
}

Examples

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:pass@127.0.0.1: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()});
}

Development

See zig build --list.

About

Zig bindings for Ada URL library.

Topics

Resources

Stars

Watchers

Forks

Languages