https://kotlinlang.org logo
#http4k
Title
# http4k
d

dave

04/17/2020, 3:49 PM
@Mehdi you can use a composite to extract the values like so:
Copy code
fun main() {
    data class Pageable(val sortAscending: Boolean, val page: Int, val maxResults: Int)

    val lens = Query.composite {
        Pageable(
            boolean().defaulted("sortAscending", true)(it),
            int().defaulted("page", 1)(it),
            int().defaulted("maxResults", 20)(it)
        )
    }

    println(lens(Request(GET, "/list?page=1")))
    // Pageable(sortAscending=true, page=1, maxResults=20)
}
👌 1
👍 1
p

pabl0rg

07/01/2020, 3:43 PM
that one's worth adding to the documentation site https://github.com/http4k/http4k/pull/453
5 Views