dave
01/02/2018, 5:44 PMimport org.http4k.core.Body
import org.http4k.core.Method.GET
import org.http4k.core.Request
import org.http4k.core.body.form
import org.http4k.lens.FormField
import org.http4k.lens.Validator
import org.http4k.lens.string
import org.http4k.lens.webForm
fun main(args: Array<String>) {
data class Student(val name: String)
val name = FormField.string().required("name")
val studentLens = Body.webForm(Validator.Strict, name).map { Student(name(it)) }.toLens()
println(
studentLens(
Request(GET, "/")
.header("Content-Type", "application/x-www-form-urlencoded")
.form("name", "bob")
)
)
}