If I use the solution you mentioned, wouldn’t I need to declare two variables, one for pathSingleSlash and another for path(“foo”)? But I think you can only pass one route variable when creating/binding the server.
I did think about the pathPrefix, but I wasn’t sure how to do that for the single slash i.e root. Can you do pathPrefix(“/“) or pathPrefix(pathSingleSlash)?
Please note that I’m using concat instead of the ~ operator which is less error prone (in my opinion).
And as a nice rule, if you have a path that should have nested paths, use always one of the path methods with prefixin its name. Otherwise, inner paths will never be matched.
I also got a good answer on stackoverflow which explains how to use multiple variables to do this: https://stackoverflow.com/a/52475792/49153. I think I’ll use a combo of both options: