Nested

Report a typo

Suppose you set up your locations this way:

@Location("api/")
class Api {
    @Location("users/")
    class Users {
        @Location("{userId}/")
        data class UserInfo(val parent: Api, val userId: Int) {
        	@Location("photos/{photoName}/")
        	data class PhotoInfo(val parent: UserInfo, val photoName: String)
        }
    }

    @Location("posts/")
    class Posts {
        @Location("{postId}/")
        data class PostInfo(val parent: Api, val postId: Int)
    }
}

Match routes with appropriate handlers:

Match the items from left and right columns
api/users/{userId}/
api/posts/
api/posts/{postId}
api/
api/users/{userId}/photos/{photoId}
get<Api> { ... }
get<Api.Posts.PostInfo> { ... }
get<Api.Users.UserInfo.PhotoInfo> { ... }
get<Api.Posts> { ... }
get<Api.Users.UserInfo> { ... }
___

Create a free account to access the full topic