Skip to content

Releases: zigzap/zap

Release v0.2.5

31 Dec 00:42
Compare
Choose a tag to compare
Release v0.2.5 Pre-release
Pre-release

ZAP Release v0.2.5

Updates

Community PR update: HTTP options support!

Hey, things are moving rapidly in ZAP land these days. StringNick (on GitHub) provided a PR adding HTTP options support!

Many thanks for the great PR!

BTW: New stuff is cooking in the 0.12.0 branch. Check out @chooky 's new mustache ;-). Maybe even in the API docs?
(zig build run-docserver is your friend)

Using it

To use in your own projects, put this dependency into your build.zig.zon:

        // zap v0.2.5
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.5.tar.gz",
            .hash = "1220c33e0ecc01b862ff6d929a948f5a8b5526a66f8d883a6d10eaff1620b8d4d605",
        }

Here is a complete build.zig.zon example:

.{
    .name = "My example project",
    .version = "0.0.1",

    .dependencies = .{
        // zap v0.2.5
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.5.tar.gz",
            .hash = "1220c33e0ecc01b862ff6d929a948f5a8b5526a66f8d883a6d10eaff1620b8d4d605",
        }
    }
}

Then, in your build.zig's build function, add the following before exe.install():

    const zap = b.dependency("zap", .{
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("zap", zap.module("zap"));
    exe.linkLibrary(zap.artifact("facil.io"));

Release v0.2.4

30 Dec 12:17
Compare
Choose a tag to compare
Release v0.2.4 Pre-release
Pre-release

ZAP Release v0.2.4

Updates

FIX tls.zig

In the heat of the action, I forgot to add tls.zig in 0.2.3. Ooops.

It's present in 0.2.4

Using it

To use in your own projects, put this dependency into your build.zig.zon:

        // zap v0.2.4
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.4.tar.gz",
            .hash = "1220b22285fd80b8e027bf877a1f66833934b8639cc4fc38c84fbbbcee5b2d6f6a8f",
        }

Here is a complete build.zig.zon example:

.{
    .name = "My example project",
    .version = "0.0.1",

    .dependencies = .{
        // zap v0.2.4
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.4.tar.gz",
            .hash = "1220b22285fd80b8e027bf877a1f66833934b8639cc4fc38c84fbbbcee5b2d6f6a8f",
        }
    }
}

Then, in your build.zig's build function, add the following before exe.install():

    const zap = b.dependency("zap", .{
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("zap", zap.module("zap"));
    exe.linkLibrary(zap.artifact("facil.io"));

Release v0.2.3

30 Dec 02:54
Compare
Choose a tag to compare
Release v0.2.3 Pre-release
Pre-release

ZAP Release v0.2.3

Updates

Refactored zap.Tls

I refactored zap.Tls to make it more zig-like:

    // this is more zig-like:
    const tls = try zap.Tls.init(.{
        .server_name = "localhost:4443",
        .public_certificate_file = CERT_FILE,
        .private_key_file = KEY_FILE,
    });
    // this, too
    defer tls.deinit();

    var listener = zap.SimpleHttpListener.init(.{
        .port = 4443,
        .on_request = on_request_verbose,
        .log = true,
        .max_clients = 100000,
        .tls = tls,
    });
    try listener.listen();

More dangerous refactorings are going to happen in the zig-0.12.0 branch, and being back-ported to master if it makes sense.

Using it

To use in your own projects, put this dependency into your build.zig.zon:

        // zap v0.2.3
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.3.tar.gz",
            .hash = "1220f8764604db85c5e598a5157f1ac21e6410e941f97e6943cddc2c9d9e12794aec",
        }

Here is a complete build.zig.zon example:

.{
    .name = "My example project",
    .version = "0.0.1",

    .dependencies = .{
        // zap v0.2.3
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.3.tar.gz",
            .hash = "1220f8764604db85c5e598a5157f1ac21e6410e941f97e6943cddc2c9d9e12794aec",
        }
    }
}

Then, in your build.zig's build function, add the following before exe.install():

    const zap = b.dependency("zap", .{
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("zap", zap.module("zap"));
    exe.linkLibrary(zap.artifact("facil.io"));

Release v0.2.2

29 Dec 17:04
Compare
Choose a tag to compare
Release v0.2.2 Pre-release
Pre-release

ZAP Release v0.2.2

Updates

TLS / HTTPS / openssl support!!!

Thanks to @ColaNova's (GitHub) work, Zap can now utilize facil.io's openssl support.

In the README, at the bottom of the list of examples, there is now a super simple https example.

It's super simple:

    const tls = zap.fio_tls_new(
        "localhost:4443",
        CERT_FILE,
        KEY_FILE,
        null, // key file is not password-protected
    );

That tls data is then passed to the SimpleHttpListener.

The example requires -Dopenssl=true on the command line. This is so that zap doesn't depend on openssl unconditionally.

Here's what happened:

openssl in facil.io

fio patches from https://github.com/CoalNova/facil.io 0.7.6-zapped branch:

* b0a7b00b - (HEAD -> 0.7.6-zapdate, coalnova/0.7.6-zapdate) Update to description (7 weeks ago) <coalnova>
* 115d07d6 - Update to delocalize OpenSSL lines (7 weeks ago) <coalnova>
* 73619a8b - Update to organize build options for TLS (7 weeks ago) <coalnova>
* 16024c0d - Update to build settings (7 weeks ago) <coalnova>
* c487bb00 - Update to fix to library name (7 weeks ago) <coalnova>
* a87818fc - Update to flag HAVE_OPENSSL as build feature (8 weeks ago) <coalnova>
* 968993b4 - Update to co/remove TODO: delete me! (8 weeks ago) <coalnova>
* 094ac99d - Update to differentiate exitcodes in TLS functions (8 weeks ago) <coalnova>
* 6d22411a - Update to expose both sets of tls functions (8 weeks ago) <coalnova>
* 007f7b19 - Update switched fio_tls_missing to fio_tls_openssl (9 weeks ago) <coalnova>
* 026c92fc - Update to expose TLS C and Header files. (9 weeks ago) <coalnova>

Changes to CoalNova's approach

!Important!: @CoalNova commented out one #if HAVE_OPENSSL in the C code. I will not do that as the build.zig will set this flag anyway. If the flag isn't specified, facil.io will compile like it did before the introduction of zap's OpenSSL support.

Addition: I had to replace the #if HAVE_OPENSSL in question to #ifdef HAVE_OPENSSL or else clang would complain. Maybe this error was the motivation for @CoalNova to remove the #if.

Also, since we don't install headers of facil.io anymore (as zap is the only consumer), I skipped installing facil.io's tls headers.

Changes to zap

Basically 2 patches:

- [Update to include basic TLS functions](https://github.com/CoalNova/zap/commit/124a3134ca71bf41635320c0bc3c098a65aba931.patch)
- [Update to expose further functions for TLS/SSL](https://github.com/CoalNova/zap/commit/14b05451989ec66e84feae9b8efc52e4f8bed1e8.patch)

Used those but skipped the build.zig.zon stuff.

OpenSSL needs to be hidden behind a custom build option orelse all projects that depend on zap will also depend on a working openssl + libcrypto dev setup: having headers and lib installed on the system.

  • make openssl a build option: -Dopenssl=true

The Example

Trying out openssl from the commandline first

Trying stuff from the command line first.

Creating the certificate and key file:

$ openssl req -x509 -nodes -days 365 -sha256 -newkey rsa:2048 -keyout mykey.pem -out mycert.pem

Serving the current dir:

$ openssl s_server -accept 4443 -cert mycert.pem -key mykey.pem -WWW

Issuing an HTTPS request:

$ curl -v -k https://localhost:4443/build.zig

The zap https example

$ zig build -Dopenssl=true https
$ zig build -Dopenssl=true run-https

It's super simple:

    const tls = zap.fio_tls_new(
        "localhost:4443",
        CERT_FILE,
        KEY_FILE,
        null, // key file is not password-protected
    );

That tls data is then passed to the SimpleHttpListener.

Using it

To use in your own projects, put this dependency into your build.zig.zon:

        // zap v0.2.2
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.2.tar.gz",
            .hash = "1220124603a1d655a772197781547c8c3d1ee58f263be29a6cd8a4b93a26407ae68b",
        }

Here is a complete build.zig.zon example:

.{
    .name = "My example project",
    .version = "0.0.1",

    .dependencies = .{
        // zap v0.2.2
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.2.tar.gz",
            .hash = "1220124603a1d655a772197781547c8c3d1ee58f263be29a6cd8a4b93a26407ae68b",
        }
    }
}

Then, in your build.zig's build function, add the following before exe.install():

    const zap = b.dependency("zap", .{
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("zap", zap.module("zap"));
    exe.linkLibrary(zap.artifact("facil.io"));

Release v0.2.1

22 Dec 03:29
Compare
Choose a tag to compare
Release v0.2.1 Pre-release
Pre-release

ZAP Release v0.2.1

Updates

Build-fix Release

The new facil.io build wasn't installing the lib, so builds broke.

This has been fixed. (Fixes #56)

Sorry for the inconvenience.

Using it

To use in your own projects, put this dependency into your build.zig.zon:

        // zap v0.2.1
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.1.tar.gz",
            .hash = "12202c27678a615f45e786aa74ce00b97a9f104f0ac4624ebc7487e66427c705cb40",
        }

Here is a complete build.zig.zon example:

.{
    .name = "My example project",
    .version = "0.0.1",

    .dependencies = .{
        // zap v0.2.1
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.1.tar.gz",
            .hash = "12202c27678a615f45e786aa74ce00b97a9f104f0ac4624ebc7487e66427c705cb40",
        }
    }
}

Then, in your build.zig's build function, add the following before exe.install():

    const zap = b.dependency("zap", .{
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("zap", zap.module("zap"));
    exe.linkLibrary(zap.artifact("facil.io"));

Release v0.2.0

19 Dec 14:44
Compare
Choose a tag to compare
Release v0.2.0 Pre-release
Pre-release

ZAP Release v0.2.0

Updates

ZAP just swallowed its dependency to our fork of facil.io

This will make hacking on facil.io (e.g. to support TLS) and future refactorings much easier.

Since ZAP is the only project that uses our facil.io fork, it made sense to ultimately integrate it.

No new features in this release!

We also got rid of the -pre version postfix. Zap has been running fine in production for > 6 months now without any hiccups 😊.

Using it

To use in your own projects, put this dependency into your build.zig.zon:

        // zap v0.2.0
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.0.tar.gz",
            .hash = "1220614483f9638f29c6c1bf07c03e945ea28a1055b82f500d3628f4134dc582b6ed",
        }

Here is a complete build.zig.zon example:

.{
    .name = "My example project",
    .version = "0.0.1",

    .dependencies = .{
        // zap v0.2.0
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.2.0.tar.gz",
            .hash = "1220614483f9638f29c6c1bf07c03e945ea28a1055b82f500d3628f4134dc582b6ed",
        }
    }
}

Then, in your build.zig's build function, add the following before exe.install():

    const zap = b.dependency("zap", .{
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("zap", zap.module("zap"));
    exe.linkLibrary(zap.artifact("facil.io"));

Release v0.1.14-pre

13 Sep 12:01
Compare
Choose a tag to compare
Release v0.1.14-pre Pre-release
Pre-release

ZAP Release v0.1.14-pre

Updates

Community Patch: Mustache Revamp Update (BREAKING CHANGE)

Thanks to @sadbeast on GitHub, new Mustache functionality has been
added: file-based and partial templates! We took the opportunity to
simplify and ziggify the interface of the Mustache related functions.

  • the MustacheLoadArgs struct has only optional slices for convenience
  • function names have been lower-cased

Here is the MustacheLoadArgs struct used for passing into the Mustache
creation functions:

/// Mustache load args used in mustacheNew
pub const MustacheLoadArgs = struct {
    /// optional filename, enables partial templates on filesystem
    filename: ?[]const u8 = null,

    /// optional string data. should be used if no filename is specified.
    data: ?[]const u8 = null,
};

You can now create a Mustache via the following functions:

/// use if both filename and data need to be passed
pub fn mustacheNew(load_args: MustacheLoadArgs) MustacheError!*Mustache;

/// use if only data needs to be passed
pub fn mustacheData(data: []const u8) MustacheError!*Mustache;

/// use if only filename needs to be passed
pub fn mustacheLoad(filename: []const u8) MustacheError!*Mustache;

So, real use cases look like this:

    const lM = try zap.mustacheLoad("./src/tests/testtemplate.html");
    const dM = try zap.mustacheData(template);

    const cM = zap.mustacheNew(.{
        .filename = "test.html",
        .data = "{{=<< >>=}}<<>testpartial.html>>",
    });

Again, many thanks to @sadbeast for improving the Mustache situation!

Using it

To use in your own projects, put this dependency into your build.zig.zon:

        // zap v0.1.14-pre
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz",
            .hash = "122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3",
        }

Here is a complete build.zig.zon example:

.{
    .name = "My example project",
    .version = "0.0.1",

    .dependencies = .{
        // zap v0.1.14-pre
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz",
            .hash = "122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3",
        }
    }
}

Then, in your build.zig's build function, add the following before exe.install():

    const zap = b.dependency("zap", .{
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("zap", zap.module("zap"));
    exe.linkLibrary(zap.artifact("facil.io"));

Release v0.1.13-pre

13 Sep 00:13
Compare
Choose a tag to compare
Release v0.1.13-pre Pre-release
Pre-release

ZAP Release v0.1.13-pre

Updates

Late Night Bugfix Release

The multi-part multi-file upload had a serious bug, and zap didn't check for potentially invalid array items correctly.

All that is fixed with this release.

Using it

To use in your own projects, put this dependency into your build.zig.zon:

        // zap v0.1.13-pre
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.13-pre.tar.gz",
            .hash = "12208cbd661a48011463659e664335ecc0ea2b121bb1ec0d4406e2326edafa864db8",
        }

Here is a complete build.zig.zon example:

.{
    .name = "My example project",
    .version = "0.0.1",

    .dependencies = .{
        // zap v0.1.13-pre
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.13-pre.tar.gz",
            .hash = "12208cbd661a48011463659e664335ecc0ea2b121bb1ec0d4406e2326edafa864db8",
        }
    }
}

Then, in your build.zig's build function, add the following before exe.install():

    const zap = b.dependency("zap", .{
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("zap", zap.module("zap"));
    exe.linkLibrary(zap.artifact("facil.io"));

Release v0.1.12-pre

12 Sep 23:40
Compare
Choose a tag to compare
Release v0.1.12-pre Pre-release
Pre-release

ZAP Release v0.1.12-pre

Updates

Multi-File Form Upload

Our power-user @edyu tested the file upload from the previous release
and reported it only supports single files.

This is fixed in this release. The bindataformpost example has been
updated, too.

Many thanks to @edyu for pushing the state of Zap forward!

Using it

To use in your own projects, put this dependency into your build.zig.zon:

        // zap v0.1.12-pre
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.12-pre.tar.gz",
            .hash = "1220326b9075805c0b9982a80fb641e04ff31deacec011b1f46de0b75d6a6af26d26",
        }

Here is a complete build.zig.zon example:

.{
    .name = "My example project",
    .version = "0.0.1",

    .dependencies = .{
        // zap v0.1.12-pre
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.12-pre.tar.gz",
            .hash = "1220326b9075805c0b9982a80fb641e04ff31deacec011b1f46de0b75d6a6af26d26",
        }
    }
}

Then, in your build.zig's build function, add the following before exe.install():

    const zap = b.dependency("zap", .{
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("zap", zap.module("zap"));
    exe.linkLibrary(zap.artifact("facil.io"));

Release v0.1.11-pre

12 Sep 17:04
Compare
Choose a tag to compare
Release v0.1.11-pre Pre-release
Pre-release

ZAP Release v0.1.11-pre

Updates

Support for binary file transmission via FORM POST

This is supposed to close #41 (thx @edyu !).

See the bindataformpost example for more details.

Using it

To use in your own projects, put this dependency into your build.zig.zon:

        // zap v0.1.11-pre
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.11-pre.tar.gz",
            .hash = "1220fc2f57c129585f511feb3cbe5dc2e9f8648f6e3c3b6f84642f812ab1efc40a14",
        }

Here is a complete build.zig.zon example:

.{
    .name = "My example project",
    .version = "0.0.1",

    .dependencies = .{
        // zap v0.1.11-pre
        .zap = .{
            .url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.11-pre.tar.gz",
            .hash = "1220fc2f57c129585f511feb3cbe5dc2e9f8648f6e3c3b6f84642f812ab1efc40a14",
        }
    }
}

Then, in your build.zig's build function, add the following before exe.install():

    const zap = b.dependency("zap", .{
        .target = target,
        .optimize = optimize,
    });
    exe.addModule("zap", zap.module("zap"));
    exe.linkLibrary(zap.artifact("facil.io"));