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

Enhance Documentation for the section Other web servers #263

Open
marcelbaumann opened this issue Feb 23, 2024 · 1 comment
Open

Enhance Documentation for the section Other web servers #263

marcelbaumann opened this issue Feb 23, 2024 · 1 comment

Comments

@marcelbaumann
Copy link

I am trying to migrate my Vaadin/javalin application to version 6.1.0.

I am using vaadin-boot library for Vaadin which already provides an embedded Jetty server. I am looking how to set up a Javalin servlet to service the REST requests and dispatch them through Javalin.

Could you provide a minimal example under https://javalin.io/documentation#other-web-servers how to set up Javalin as a servlet. Or just provide pointers so that I can write an example.

The changes in version 6.x seems to change the approach how to do it. In the older versions we could do:

@WebServlet(name = "MyJavalinServlet", urlPatterns = {"/rest/*"})
public class MyJavalinServlet extends HttpServlet {
    private final JavalinServlet javalin = Javalin.createStandalone()
            .get("/rest", ctx -> ctx.result("Hello!"))
            .javalinServlet();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        javalin.service(req, resp);
    }
}

How should we do it with the version 6.x.

Thanks in advance.

@tipsy
Copy link
Member

tipsy commented Feb 23, 2024

Can you try

@WebServlet(name = "MyJavalinServlet", urlPatterns = {"/rest/*"})
public class MyJavalinServlet extends HttpServlet {
    private final JavalinServlet javalin = Javalin.create()
            .get("/rest", ctx -> ctx.result("Hello!"))
            .javalinServlet();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        javalin.service(req, resp);
    }
}

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants