1

There have been a lot of changes to the configuration in Javalin 5. One thing that used to work in previous versions is to "ignore trailing slashes" like this:

var javalin = Javalin.create(cfg -> {
    cfg.ignoreTrailingSlashes = true;
}).start(8080);

But I cannot seem to find this setting in version 5. So the question is, how do you enable "ignore trailing slashes" in Javalin version 5?

Johan
  • 37,479
  • 32
  • 149
  • 237
  • 2
    related, same author: [How to enable "dev logging" in Javalin 5?](https://stackoverflow.com/q/74807996/16320675) – user16320675 Dec 15 '22 at 07:31
  • Yes that was me, I asked these as two different questions because they are two different settings. – Johan Dec 15 '22 at 07:39
  • Okay, I can merge them if that is more appropriate? – Johan Dec 15 '22 at 07:57
  • 1
    I don't think a merge is needed, I just wanted to add a link to related problem – user16320675 Dec 15 '22 at 09:54
  • The [Javalin v4 to v5 migration guide](https://javalin.io/migration-guide-javalin-4-to-5) may help with at least some of these questions. For example, there is a section for "Configuration changes". You may already have seen it - but this link may help others. – andrewJames Dec 15 '22 at 13:34

1 Answers1

3

The setting is now moved to 'routing config' you can now set it as below:

Javalin.create(config -> {
    config.routing.ignoreTrailingSlashes = true; 
});

See the documentation here - https://javalin.io/documentation#routingconfig

Vini
  • 8,299
  • 11
  • 37
  • 49