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 - Add ability to configure routing for an existing socket #7702

Closed
romain-grecourt opened this issue Oct 2, 2023 · 0 comments · Fixed by #7705
Closed

4.x - Add ability to configure routing for an existing socket #7702

romain-grecourt opened this issue Oct 2, 2023 · 0 comments · Fixed by #7705
Assignees
Labels
4.x Version 4.x webserver
Milestone

Comments

@romain-grecourt
Copy link
Contributor

romain-grecourt commented Oct 2, 2023

In 3.x users could define "named" sockets in configuration and set-up routing for those sockets programmatically.

In the current 4.x state (at least in 4.0.0-RC1), the only way to set-up routing for a socket is when creating the socket via the putSocket method on the server builder.

The workaround to emulate the 3.x use-case is to re-create the socket:

.putSocket("admin", socket -> socket.from(server.sockets().get("admin"))
                        .routing(Main::adminSocket))

Side by side comparison

Given the following application.yaml:

server:
  port: 8080
  host: "localhost"
  sockets:
    - name: "admin"
      port: 8081

In 3.x:

WebServer.builder(createPublicRouting())
    .config(config.get("server"))
    .addNamedRouting("admin", Routing.builder()
    .get("/admin", (req, res) -> res.send("Hello Admin!!"))
    .build())

In 4.x:

WebServer.builder()
        .config(config.get("server"))
        .update(builder -> builder
                .putSocket("admin", socket -> socket.from(builder.sockets().get("admin"))
                        .routing(routing -> routing.get("/admin", (req, res) -> res.send("Hello Admin!!")))))
        .build()
@barchetta barchetta added this to the 4.0.0 milestone Oct 2, 2023
romain-grecourt added a commit to romain-grecourt/helidon that referenced this issue Oct 3, 2023
- Update WebServerConfigBlueprint and LoomServer
- Update multiport example to use the new API
- Fix multiport example README.md and dependencies (/observe and dependencies)

Fixes helidon-io#7702
romain-grecourt added a commit to romain-grecourt/helidon that referenced this issue Oct 3, 2023
- Update WebServerConfigBlueprint and LoomServer
- Update multiport example to use the new API
- Fix multiport example README.md and dependencies (/observe and dependencies)

Fixes helidon-io#7702
romain-grecourt added a commit to romain-grecourt/helidon that referenced this issue Oct 3, 2023
- Update WebServerConfigBlueprint and LoomServer
- Update multiport example to use the new API
- Fix multiport example README.md and dependencies (/observe and dependencies)

Fixes helidon-io#7702
@romain-grecourt romain-grecourt linked a pull request Oct 3, 2023 that will close this issue
romain-grecourt added a commit that referenced this issue Oct 3, 2023
- Update WebServerConfigBlueprint and LoomServer
- Update multiport example to use the new API
- Fix multiport example README.md and dependencies (/observe and dependencies)

Fixes #7702
dalexandrov pushed a commit to dalexandrov/helidon that referenced this issue Oct 17, 2023
…7705)

- Update WebServerConfigBlueprint and LoomServer
- Update multiport example to use the new API
- Fix multiport example README.md and dependencies (/observe and dependencies)

Fixes helidon-io#7702
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x Version 4.x webserver
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants