Skip to content

Provide defaults to unimplemented methods in endpoints for App style api. #171

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

Merged
merged 1 commit into from
Jul 22, 2025

Conversation

Tesseract22
Copy link
Contributor

Make get, post, ... methods optional in endpoint. Check whether these method exist at comptime. When no corresponding method is provided, the handler simply return immediately.

Since it uses comptime, hopefully it should not add any checks at runtime.

Also since App shares a global state (_static), I think it makes more sense NOT accept an app instance in the apis. So:

old:

var app = App.init(...);
try app.register(...);

proposal:

App.init(...);
App.register(...);

See examples/app/.

Make `get`, `post`, ... methods optional. Check whether these method
exist at comptime. When no corresponding method is provided,
the handler simply return immediately.

Since it uses comptime, hopefully it should not add any checks at
runtime.
@renerocksai
Copy link
Member

Awesome! And sorry for the delay. The App stuff is a bit confusing wrt the Zig convention TypeName, instance_name, but I think I can live with that 😄.

@renerocksai renerocksai merged commit 29d3398 into zigzap:master Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants