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

4.x: Make HttpRouting an interface #8572

Closed
VerKWer opened this issue Mar 27, 2024 · 1 comment · Fixed by #8523
Closed

4.x: Make HttpRouting an interface #8572

VerKWer opened this issue Mar 27, 2024 · 1 comment · Fixed by #8523
Assignees
Labels
4.x Version 4.x design This issue requires design/architecture decisions enhancement New feature or request P3 webserver

Comments

@VerKWer
Copy link
Contributor

VerKWer commented Mar 27, 2024

Environment Details

  • Helidon Version: 4.0.6
  • Helidon SE

Problem Description

This is more of an improvement proposal but does address an actual issue as well (though probably not one that people will encounter in practice). Currently HttpRoute is an interface, whereas HttpRouting isn't (it's a final class). It would be good to be consistent and make both interfaces, as it allows for more configurability, and almost everything else that can be specified in a WebServer builder is an interface.

Use Case

Being able to implement your own HttpRouting type can be useful when moving an existing service to Helidon; for example if there already is custom routing logic for it.

Issue to Solve Along the Way

As for the actual issue (one might call it a bug) I encountered while working on this: other routing classes (such as GrpcRouting) aren't final, which one might understand as Helidon supporting custom implementations. However, if one does so, requests aren't properly routed anymore. The reason for this is that the RouterImpl indexes Routing instances by their class and its routing method is always called with a fixed class. Therefore, when trying to use a custom implementation, it wouldn't be found.

This issue needs to be addressed if one wants to make HttpRouting an interface. As a side-effect it would fix the "bug" just described, allowing the RouterImpl to handle custom implementations of other routing types.

Compatibility

This change should be (mostly) backwards compatible. Currently, the HttpRouting class is final (so no existing code can break because it subclasses HttpRouting) and its constructor is private (so no existing code can break because the constructor won't exist anymore).

Other Considerations

Even with HttpRouting becoming an interface, it wouldn't be straightforward to use a custom implementation. The WebServer.Builder.routing method takes a HttpRouting.Builder; providing a HttpRouting instance directly isn't possible. So, to use a custom routing implementation, one would also have to also create a custom HttpRouting.Builder, whose build method returns an instance of the custom routing implementation. This isn't great but also not a big deal as most users won't be doing this. Anyway, improving this is out of scope of this issue.

@tomas-langer tomas-langer added enhancement New feature or request webserver design This issue requires design/architecture decisions labels Mar 28, 2024
@tomas-langer tomas-langer self-assigned this Mar 28, 2024
@m0mus m0mus added the 4.x Version 4.x label Mar 28, 2024
@m0mus m0mus added the P3 label Mar 28, 2024
@tomas-langer
Copy link
Member

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x design This issue requires design/architecture decisions enhancement New feature or request P3 webserver
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants