Preliminary support for query parameters
This commit is contained in:
parent
0e7484543e
commit
1aec8031e6
2 changed files with 3 additions and 1 deletions
|
@ -85,8 +85,9 @@ pub fn Router(comptime ServerContext: type, comptime RequestContext: type) type
|
|||
};
|
||||
|
||||
pub fn dispatch(self: Self, sctx: ServerContext, rctx: RequestContext, method: std.http.Method, path: []const u8) anyerror!void {
|
||||
const eff_path = std.mem.sliceTo(std.mem.sliceTo(path, '#'), '?');
|
||||
for (self.routes) |r| {
|
||||
r.dispatch(sctx, rctx, method, path) catch |err| switch (err) {
|
||||
r.dispatch(sctx, rctx, method, eff_path) catch |err| switch (err) {
|
||||
error.RouteNotApplicable => continue,
|
||||
else => return err,
|
||||
};
|
||||
|
|
|
@ -43,6 +43,7 @@ pub fn parse(url: []const u8) !Url {
|
|||
|
||||
pub fn getQuery(self: Url, param: []const u8) ?[]const u8 {
|
||||
var key_start: usize = 0;
|
||||
std.log.debug("query: {s}", .{self.query});
|
||||
while (key_start < self.query.len) {
|
||||
const key_end = for (self.query[key_start..]) |ch, i| {
|
||||
if (ch == '=') break key_start + i;
|
||||
|
|
Loading…
Reference in a new issue