Skip to content

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

Merged
renerocksai merged 1 commit into
zigzap:masterfrom
Tesseract22:master
Jul 22, 2025
Merged

Provide defaults to unimplemented methods in endpoints for App style api.#171
renerocksai merged 1 commit into
zigzap:masterfrom
Tesseract22:master

Conversation

@Tesseract22

Copy link
Copy Markdown
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
Copy Markdown
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