// api/articles/article/Comments.kt
@Api
fun comments(ctx: ApiContext) {
val articleId = ctx.params.getValue("article")
// ...
}
[!IMPORTANT]
Dev note: Make sure that you can define both an @Api endpoint AND a package mapping both, because users will want to
be able to GET both "/articles/{article}" AND "/articles/{article}/comments".
Currently, we only support this for pages. We should also support it for API endpoints:
See also: https://stackoverflow.blog/2020/03/02/best-practices-for-rest-api-design/#h2-2eb87cd076da0
In Kobweb, this would look like
Note that users will probably also want to support nesting this feature, so we need to support
@PackageMapping
as well.From https://stackoverflow.blog/2020/03/02/best-practices-for-rest-api-design/#h2-8ec448c6df8c0
then in Kotlin: