vaadin / quarkus

An extension to Quarkus to support Vaadin Flow
Apache License 2.0
28 stars 3 forks source link

Integrating Vaadin Flow to an existing Quarkus project. Can't get the routing to work without creating my own VaadinServlet #148

Closed preslavrachev closed 1 month ago

preslavrachev commented 2 months ago

I am creating an administration dashboard using Vaadin, which I am going to add to my existing Quarkus app. Unfortunately, the routing does not seem to work by defaul, as the root of the application has naturally been mapped to a Quarkus route already. I noticed that the Vaadin router will try to hook itself to /* causing it get shadowed.

As I only want Vaadin for that one admin use case, I discovered that I can inject a custom replacement for the QuarkusVaadinServlet that is mapped to /admin/* instead:

@WebServlet(urlPatterns = "/admin/*", name = "AdminServlet", asyncSupported = true)
public class AdminServlet extends QuarkusVaadinServlet {/* ... */}

At a quick glance, this seems to work, but as it has not been documented anywhere else, I am obliged to ask. Is this the preferred way to overcome my original issue. I read somewhere that I could set a property for the mapping, but this did not work in my case.

mcollovati commented 2 months ago

I can confirm that currently extending QuarkusVaadinServlet is the way to go. Configuring mapping is supported in Spring Boot, but not on Quarkus.

I'll mark this issue as an enhancement, since configuring the mapping also in Quarkus looks a useful addition.

preslavrachev commented 2 months ago

@mcollovati Thanks for confirming! In the meantime, shall I submit a small PR for adding this knowledge to the documentation? I think it will be useful for many in my situation.

mcollovati commented 2 months ago

Contributions are more than welcome, so, please, go ahead.

Here's the link to the docs repo https://github.com/vaadin/docs Please make sure the PR targets next branch

preslavrachev commented 2 months ago

@mcollovati PR sent, feel free to check it out and merge if you don't see any issues.

mcollovati commented 2 months ago

@preslavrachev Thank you! I'll review it as soon as possible

mcollovati commented 1 month ago

Closing, as documentation has been updated in https://github.com/vaadin/docs/pull/3353 and merged.