jooby-project / jooby

The modular web framework for Java and Kotlin
https://jooby.io
Apache License 2.0
1.7k stars 200 forks source link

decoders not shared to the mounted routes #3400

Closed kliushnichenko closed 4 months ago

kliushnichenko commented 4 months ago

Unlike jooby2 in 3.x decoders installed in the main app is not applied to the routes were mounted from another app

class AppA extends Jooby {
    {
        post("/pets", ctx -> ctx.body(Pet.class));
    }
}

class MainApp extends Jooby {
    {
       install(new JacksonModule());
       mount(new AppA());
    }
  }

Now hit post("/pets") and you will catch UnsupportedMediaType error, cause Jackson decoder was overridden at the copy route stage. Hope it wasn't changed intentionally and we can return the Jooby2 behaviour

jknack commented 4 months ago

there is a slightly difference between mount(Router) and install(Router). In your case install should work. Mount only import routes into the main app.

kliushnichenko commented 4 months ago

yeah, indeed install works as expected, thank you