Skip to content
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

Prefer to use the Interceptor API over Pedestal's interceptor "Helpers" #12

Open
ohpauleez opened this issue Jun 9, 2016 · 4 comments

Comments

@ohpauleez
Copy link

Pedestal's Interceptor Helpers are discouraged, and at some point, will be removed from Pedestal all together. Instead, you should use the interceptor API directly (via the interceptor function). You should avoid using macros to generate Interceptors, as this can often break AOT compilation.

@oliyh
Copy link
Owner

oliyh commented Jun 9, 2016

Hi @ohpauleez
I understand the drive to eliminate macros, and can work on this, but the fact remains that the helpers are extremely... helpful; I find they aid clarity quite a bit. For the small number of common patterns that exist, why are helpers frowned upon (assuming they were reimplemented as normal functions)?

@ohpauleez
Copy link
Author

ohpauleez commented Jun 9, 2016

The function-form of the helpers aren't frowned upon (although I tend to rarely use them), only the def* macro versions.

In most cases, {:name ::blah :enter (fn [ctx] ...)} reads just as clear, without needing to understand what before/after/around/handler all do. It eliminates surface area when attempting to comprehend the entire system. The macro versions can be dangerous because they can end up breaking AOT compilation (based on how the 3-levels of macro nesting resolve all the expansion).

Everything in Pedestal is an interceptor that takes and returns a context, and I think the helpers muddy that a bit. They were needed before there was a unified, extensible API, but that API now exists.

@oliyh
Copy link
Owner

oliyh commented Jun 9, 2016

Thanks, I will aim to remove the macros but I think with the extra steps involved in attaching the Swagger metadata as well there is still a use case for helper functions.

@ohpauleez
Copy link
Author

Cool, let me know if you need help with anything!

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

No branches or pull requests

2 participants