-
Notifications
You must be signed in to change notification settings - Fork 596
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
[Discuss] Prevent construction of impossible routes with types #1021
Comments
We can open issues on the intellij issue tracker and mark them as subsystem: akka, I know the guys are looking for ideas for features to implement :) |
This to me is somewhat related with #201 assuming both require the ability to do introspection on the AST (or abstract route tree). Short of moving to a more static way of representing routes maybe scala.meta can be of use. |
I think it would be overkill to try to fix that with types. We would have to find a simple encoding that would allow to parametrize all I think we should rather invest in a generic tracing infrastructure for Akka HTTP routes that would should show the path a request has taken through the routing tree. In the best case it would should better why a path didn't match at a certain point. A lighter debugging tool could be more informative rejection messages (behind a "debugging mode" config flag) that would directly point to the issue in the rejection coming from the accidental More generally: one of the problems is that it is always easier to say why a code path was taken but always hard to say why a code path was not taken (there are only so many ways to call something, but unlimited ways of not calling something). In Akka HTTP an additional problem is that the route tree is not static but built dynamically so that routes that are not taken are not even existent. |
I think I should use the "crazy idea" tag @ktoso was mentioning in some other ticket 😃 I agree with a better debugging pointing where a rejection happened and other ones in this direction. |
I don't see a way we could solve this... closing until we come up with a really crazy idea? :) |
This issue falls more into the wishlist area, and I think it makes more sense to consider it if (when) wanting to apply a lifting to the current DSL.
There are some directives that makes no sense to nest inside each other. For example:
pathPrefix
inside apath
pathEnd
The current DSL doesn't prevent nor help the developer to catch such errors, and in some cases, it might lead to some wasted time debugging why a route is not called when it should.
It would be good if all those impossible scenarios were caught by the compiler.
Another alternative would be to convince some IDE maintainers to include such checks as warnings.
The text was updated successfully, but these errors were encountered: