Put mount base url in context
This commit is contained in:
parent
8edf661afe
commit
0f5751e7ed
1 changed files with 10 additions and 1 deletions
|
@ -465,7 +465,16 @@ pub fn Mount(comptime route: []const u8) type {
|
||||||
var new_ctx = ctx;
|
var new_ctx = ctx;
|
||||||
new_ctx.path = args.path;
|
new_ctx.path = args.path;
|
||||||
|
|
||||||
|
if (@hasField(@TypeOf(new_ctx), "mounted_at")) {
|
||||||
|
new_ctx.mounted_at = try std.fmt.allocPrint(ctx.allocator, "/{s}/{s}", .{
|
||||||
|
std.mem.trim(u8, ctx.mounted_at, "/"),
|
||||||
|
std.mem.trim(u8, route, "/"),
|
||||||
|
});
|
||||||
|
defer ctx.allocator.free(new_ctx.mounted_at);
|
||||||
return next.handle(req, res, new_ctx, {});
|
return next.handle(req, res, new_ctx, {});
|
||||||
|
} else {
|
||||||
|
return next.handle(req, res, addField(new_ctx, "mounted_at", std.mem.trim(u8, route, "/")), {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue