diff --git a/README.md b/README.md index c6f059e..9dcc37e 100644 --- a/README.md +++ b/README.md @@ -73,16 +73,21 @@ fn onRequest(arena: *std.heap.ArenaAllocator, request: Request) !void { ## Depend -`build.zig.zon` +Run the following command in zig project root directory. + +```sh +zig fetch --save git+https://github.com/Cloudef/zig-router.git +``` + +In `build.zig` file add the following for whichever modules `zig-router` is required. + ```zig -.zig_router = .{ - .url = "https://github.com/Cloudef/zig-router/archive/{COMMIT}.tar.gz", - .hash = "{HASH}", -}, +const zig_router = b.dependency("zig-router", .{}); +exe.root_module.addImport("zig-router", zig_router.module("zig-router")); ``` -`build.zig` +You can now import the `zig-router` from zig code. + ```zig -const zig_router = b.dependency("zig_router", .{}).module("zig-router"); -exe.root_module.addImport("zig-router", zig_router); +const router = @import("zig-router"); ``` diff --git a/flake.nix b/flake.nix index b936151..5456663 100644 --- a/flake.nix +++ b/flake.nix @@ -107,18 +107,23 @@ ## Depend - `build.zig.zon` + Run the following command in zig project root directory. + + ```sh + zig fetch --save git+https://github.com/Cloudef/zig-router.git + ``` + + In `build.zig` file add the following for whichever modules `zig-router` is required. + ```zig - .zig_router = .{ - .url = "https://github.com/Cloudef/zig-router/archive/{COMMIT}.tar.gz", - .hash = "{HASH}", - }, + const zig_router = b.dependency("zig-router", .{}); + exe.root_module.addImport("zig-router", zig_router.module("zig-router")); ``` - `build.zig` + You can now import the `zig-router` from zig code. + ```zig - const zig_router = b.dependency("zig_router", .{}).module("zig-router"); - exe.root_module.addImport("zig-router", zig_router); + const router = @import("zig-router"); ``` EOF '');