Ktor Locations Slug

I’m trying to write a slug for Locations and am struggling to figure out exactly how to do it.

@Location("/files")
class Files{
    @Location("/view/{id}/{slug?}")
    data class View(val files: Files, val id: String, val slug: String?)
}

The following should match(i have IgnoreTrailingSlash installed):
/view/fileId
/view/fileId/
/view/fileId/some-description
/view/fileId/some-description/

having additional segment match would be fine, but unimportant:
/view/fileId/some-description/test123

I don’t actually care about the slug value, just that optionally an additional path segment can be passed at the end.

Is there something I’m missing?

Thanks.

I don’t have a running Ktor project right now to experiment, but I believe you can use a tailcard:

@Location("/view/{id}/{...}")

That’s one of the things I had tried before.

The following code throws an exception on build:

@Location("/files")
class Files {
    @Location("/view/{id}/{...}")
    data class View(val files: Files, val id: String)
}

Exception in thread “main” io.ktor.locations.LocationRoutingException: Path parameters ‘’ are not bound to ‘class com.domain.plugins.Files$View’ properties

The same exception is also thrown for

@Location("/files")
class Files {
    @Location("/view/{id}/{...}")
    data class View(val files: Files, val id: String, val slug: String)
}

If I remember correctly, you need to use Array<String> or maybe List<String>. This feature lacks documentation, I read the source code.

Thanks. I had tried Array<String> with no luck, but for some reason did not try List<String>.
The following works as expected. Path parameters beyond {id} are optional and captured in the list.

@Location("/files")
class Files {
    @Location("/view/{id}/{slug...}")
    data class View(val files: Files, val id: String, val slug: List<String>)
}