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 #8523

Merged
merged 2 commits into from
Apr 3, 2024
Merged

Conversation

VerKWer
Copy link
Contributor

@VerKWer VerKWer commented Mar 22, 2024

Description

Currently HttpRoute is an interface whereas HttpRouting isn't. 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. In addition, making this change seems ideologically correct because it allows for more configurability, and almost everything else that can be specified in a WebServer builder is an interface.

Another issue that's addressed as a side-effect is that while other routing classes (e.g. GrpcRouting) aren't final, using a custom implementation isn't easily possible. 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.

Documentation

The HttpRouting class is replaced by an interface and all implementation/builder code previously in it is moved to the new package-private HttpRoutingImpl class. This should not break existing applications because HttpRouting was final (so no subclasses can be defined) and its constructor was private (so it cannot be called directly).

The routingType() method is added to the Routing interface with a default implementation consistent with the previous behaviour. Its result is used by RouterImpl to determine the correct Routing instance to use. I'm not sure returning a Class here is the best solution, but it is what was previously used.

Resolves #8572

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Mar 22, 2024
@tomas-langer
Copy link
Member

Hello @VerKWer - I have approved the pipeline run.
In general we start from an issue in our issue tracker. If there is none yet created, kindly create it and link it to your PR. If there is one, just link it. This is the kind of work that requires approval of design. Although I agree with the approach you have taken, it would be better to discuss this first on an issue, or through our Slack channel, to make sure we are OK with such a change.

Also this is going into the internals of WebServer, so I will need to spend a bit of time making sure this does not introduce any kind of backward incompatibility.

Thanks for your contribution!

@tomas-langer tomas-langer self-assigned this Mar 27, 2024
@tomas-langer tomas-langer added webserver design This issue requires design/architecture decisions contribution A PR contributed from outside of Helidon team. labels Mar 27, 2024
@VerKWer
Copy link
Contributor Author

VerKWer commented Mar 27, 2024

Hey @tomas-langer! Thank you for having a look at the PR and pointing out the proper procedures; this is my first time contributing to Helidon, and I'll gladly create an issue to link to.

I did have similar thoughts about maybe first reaching out to check whether my contribution was welcome. To that end, I asked in the Nima Slack channel at the time but realise only now that that was more than four months ago on November 14 (time really does fly). I can't see the thread anymore, but I think it was you, who answered back then that you'd be open for the change, which was very encouraging. Still, I'll make sure to communicate better for future contributions, and to always create an issue first.

@tomas-langer tomas-langer merged commit ee86250 into helidon-io:main Apr 3, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution A PR contributed from outside of Helidon team. design This issue requires design/architecture decisions OCA Verified All contributors have signed the Oracle Contributor Agreement. webserver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.x: Make HttpRouting an interface
2 participants