Update server.zig
This commit is contained in:
parent
6614df2024
commit
104f2c7649
1 changed files with 4 additions and 1 deletions
|
@ -58,9 +58,12 @@ pub const Server = struct {
|
||||||
var req_path = r[0];
|
var req_path = r[0];
|
||||||
// Trim a possible trailing slash from Route path in order to accept it during the matching process.
|
// Trim a possible trailing slash from Route path in order to accept it during the matching process.
|
||||||
if (req_path.len > 1) req_path = std.mem.trimRight(u8, req_path, "/");
|
if (req_path.len > 1) req_path = std.mem.trimRight(u8, req_path, "/");
|
||||||
|
// Check if there is a match
|
||||||
if (eql(u8, req_path, req.uri)) {
|
if (eql(u8, req_path, req.uri)) {
|
||||||
// If URI matches, change response with handling function.
|
// Change response with handling function in case of match.
|
||||||
res = r[1](req);
|
res = r[1](req);
|
||||||
|
// Exit loop in case of match
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Stringify the Response and send it to the client.
|
// Stringify the Response and send it to the client.
|
||||||
|
|
Loading…
Add table
Reference in a new issue