Case Insensitive routing with akka-http

Is there a global setting which allows the Path matchers to work in a case insensitive way?

I’ve a very specific case where I want to do


and want it to be matched without being case sensitive. I do know we could have
pathPrefix(Segment) => (segment) then convert segment toLower and match, but the above case the string has to specifically match in a case insensitive way, is there a way to do this?

Hi Adarsh,

Akka HTTP tries to adhere to the standards, and according to them, URL paths are case sensitive. There isn’t any configuration parameter where this can be toggled or changed.

Of course, you can always write your own path directive that checks prefixes in a case insensitive way. One way to do so is to map the request’s path to be lowercase and then convert the path prefixes strings also to lowercase. This should do the trick.

It could be something like this:

private def caseInsensitivePathPrefix(path: String)(inner: Route) = {
    mapRequest ( request => request.copy(uri = Uri(request.uri.path.toString.toLowerCase))){

Please note that this is a quick code I hack together on the spot, check it before using it in production.


Thanks Josep, sure, I just wanted to know the right direction to look at. thanks for the quick snippet!

You’re welcome!