javajavalin

How to ignore trailing slashes in Javalin 5?


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?


Solution

  • 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