elect
03/18/2024, 10:42 AM-d '{"ref":"refs/heads/featureA","sha":"aa218f56b14c9653891f9e74264a383fa43fefbd"}'
fredrik.nordin
03/18/2024, 11:56 AMJames Richardson
03/18/2024, 12:14 PMimport org.http4k.core.Body
import org.http4k.core.Method
import org.http4k.core.Request
import org.http4k.core.Uri
import org.http4k.core.with
import org.http4k.format.Jackson.json
import org.http4k.format.Jackson.asJsonObject
println(Request(<http://Method.POST|Method.POST>, Uri.of("")).body("""{"ref":"refs/heads/featureA","sha":"aa218f56b14c9653891f9e74264a383fa43fefbd"}"""))
val body = Body.json().toLens()
println(Request(<http://Method.POST|Method.POST>, Uri.of("")).with(body of mapOf("ref" to "refs/heads/featureA", "sha" to "aa218f56b14c9653891f9e74264a383fa43fefbd").asJsonObject()))
something like those two? - there are quite a few ways, just depending on how you're feeling... - you can of course make DTO types etc...elect
03/18/2024, 3:35 PMelect
03/18/2024, 3:36 PM.json()
exactly? This?
import org.http4k.format.KotlinxSerialization.json
James Richardson
03/18/2024, 3:36 PMelect
03/18/2024, 3:38 PMelect
03/18/2024, 3:38 PMelect
03/18/2024, 3:39 PMJames Richardson
03/18/2024, 3:39 PMelect
03/18/2024, 3:41 PMJames Richardson
03/18/2024, 3:43 PMimport org.http4k.format.Jackson.auto
data class RefSha(val ref: String, val sha: String)
val autoBody = Body.auto<RefSha>().toLens()
println(Request(<http://Method.POST|Method.POST>, Uri.of("")).with(autoBody of RefSha(ref="refs/heads/featureA", sha="aa218f56b14c9653891f9e74264a383fa43fefbd")))
elect
03/18/2024, 3:44 PMJames Richardson
03/18/2024, 3:44 PM