Compare commits

..

3 commits
v0.1.0 ... main

Author SHA1 Message Date
3826058062
Version 0.1.1 2024-10-18 15:11:48 +02:00
4649021978
Correctly add pre handlers and post handlers to routes nodes. 2024-10-18 15:09:11 +02:00
0e9cdcb6eb
Root imports cleanup. 2024-10-16 11:59:06 +02:00
5 changed files with 10 additions and 5 deletions

View file

@ -28,7 +28,7 @@ _Zouter_ is an HTTP router library for Zig **zap** HTTP server. It's made to eas
## Versions ## Versions
Zouter 0.1.0 is made for zig 0.13.0 and tested with zap 0.8.0. Zouter 0.1.1 is made for zig 0.13.0 and tested with zap 0.8.0.
## How to use ## How to use
@ -37,7 +37,7 @@ Zouter 0.1.0 is made for zig 0.13.0 and tested with zap 0.8.0.
In your project directory: In your project directory:
```shell ```shell
$ zig fetch --save https://code.zeptotech.net/zedd/zouter/archive/v0.1.0.tar.gz $ zig fetch --save https://code.zeptotech.net/zedd/zouter/archive/v0.1.1.tar.gz
``` ```
In `build.zig`: In `build.zig`:

View file

@ -1,6 +1,6 @@
.{ .{
.name = "zouter", .name = "zouter",
.version = "0.1.0", .version = "0.1.1",
.minimum_zig_version = "0.13.0", .minimum_zig_version = "0.13.0",
.dependencies = .{ .dependencies = .{
@ -14,5 +14,7 @@
"build.zig", "build.zig",
"build.zig.zon", "build.zig.zon",
"src", "src",
"README.md",
"LICENSE",
}, },
} }

View file

@ -1,4 +1,3 @@
const std = @import("std");
const router = @import("router.zig"); const router = @import("router.zig");
const route = @import("route.zig"); const route = @import("route.zig");

View file

@ -195,6 +195,8 @@ pub const RouteNode = struct {
.handle = definition.handle, .handle = definition.handle,
.handleNotFound = definition.handleNotFound, .handleNotFound = definition.handleNotFound,
.handleError = definition.handleError, .handleError = definition.handleError,
.preHandle = definition.preHandle,
.postHandle = definition.postHandle,
}); });
} }
else else
@ -203,6 +205,8 @@ pub const RouteNode = struct {
childTree.handle = definition.handle; childTree.handle = definition.handle;
childTree.handleNotFound = definition.handleNotFound; childTree.handleNotFound = definition.handleNotFound;
childTree.handleError = definition.handleError; childTree.handleError = definition.handleError;
childTree.preHandle = definition.preHandle;
childTree.postHandle = definition.postHandle;
if (definition.children) |children| if (definition.children) |children|
{ // If there are children, recursively parse them. { // If there are children, recursively parse them.

View file

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const zouter = @import("../src/root.zig"); const zouter = @import("zouter");
test { test {
// try std.testing.refAllDecls(zouter); // try std.testing.refAllDecls(zouter);