Ktor: define route for URL with and without tailing slash

Viewed 136

I am trying to learn Ktor, when responding to a GET request, I found that the trailing slash is treated as two routes, for example:

/greet?name=john
/greet/?name=john

Is it possible to define one route for the above two URLs, which is to handle trailing slash automatically?

2 Answers

In your Application.module() or Application.configureRouting() add this:

install(IgnoreTrailingSlash)
Related