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

[Discuss] Prevent construction of impossible routes with types #1021

Closed
jlprat opened this issue Apr 9, 2017 · 5 comments
Closed

[Discuss] Prevent construction of impossible routes with types #1021

jlprat opened this issue Apr 9, 2017 · 5 comments
Labels
discuss Tickets that need some discussion before proceeding

Comments

@jlprat
Copy link
Contributor

jlprat commented Apr 9, 2017

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:

  • Any of the method directives
  • Nest a pathPrefix inside a path
  • Any path directive after 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.

@jlprat jlprat added the discuss Tickets that need some discussion before proceeding label Apr 9, 2017
@ktoso
Copy link
Contributor

ktoso commented Apr 10, 2017

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 :)

@jonas
Copy link
Contributor

jonas commented Apr 12, 2017

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.

@jrudolph
Copy link
Contributor

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 Route and Directive with all of the properties we want to check and then propagate that everywhere correctly. That's just not feasible using the Scala type system.

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 path instead of pathPrefix.

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.

@jlprat
Copy link
Contributor Author

jlprat commented Apr 18, 2017

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.

@raboof
Copy link
Contributor

raboof commented Jun 12, 2018

I don't see a way we could solve this... closing until we come up with a really crazy idea? :)

@raboof raboof closed this as completed Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Tickets that need some discussion before proceeding
Projects
None yet
Development

No branches or pull requests

5 participants