-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile-time routes definition #19
Conversation
…outer parts in router directory. + Define routes at compile-time. + Add router user data, usable from context. * Adapt routes for fully compile-time definitions, without runtime data handling. * Change serve_fs_dir to use resolve instead of realpath (see ziglang/zig#19353). - Remove per-route user data. WIP: filesystem serve.
Hi, thanks for submitting this! I've been busy recently but I'll take a look at in the coming days! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty solid implementation wise and I'm pretty happy about this so good job! I left some notes about naming just because I think it's important for ease of maintainability. I also appreciate all of the documentation and examples being updated along with the code :)
I should probably formalize this somewhere but the style I try to use is:
snake_case
for variables and methods on structs. (This is one that came up the most, not a giant issue just a style one).- '_name
for types that need compile time parameters. (You were fine on this aside from that one
_self`) - Avoid file as struct.
- Zig Style Guide for the rest.
Tbh, I noticed it, I did that to see how important was this naming convention to you. My opinion is that it's a bit surprising to use this naming convention when all Zig is made different, but I'll change my code to use |
…found handler to be called no matter the used method.
As discussed in #18, here is a pull request for compile-time routes definition.
I tried to keep exactly the same features, but keeping per-route custom data wasn't possible because routes couldn't take runtime values anymore. I created a
state
variable in context, withUserState
type, set on server type definition.There are also 2 things that I'd like to change, that I'll describe in comments.