diff --git a/gradle.properties b/gradle.properties index 8733a24..e0366cc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -invirtVersion = 0.8.26 +invirtVersion = 0.8.27 kotlinVersion = 1.9.23 http4kVersion = 5.17.0.0 mockkVersion = 1.13.9 diff --git a/invirt-http4k/src/main/kotlin/invirt/http4k/handlers/HealthCheck.kt b/invirt-http4k/src/main/kotlin/invirt/http4k/handlers/HealthCheck.kt index 8a96e7e..27608b4 100644 --- a/invirt-http4k/src/main/kotlin/invirt/http4k/handlers/HealthCheck.kt +++ b/invirt-http4k/src/main/kotlin/invirt/http4k/handlers/HealthCheck.kt @@ -2,8 +2,9 @@ package invirt.http4k.handlers import invirt.http4k.GET import invirt.http4k.jsonLens -import invirt.http4k.ok -import invirt.http4k.views.ok +import org.http4k.core.Response +import org.http4k.core.Status +import org.http4k.core.with import org.http4k.routing.RoutingHttpHandler import org.http4k.routing.routes @@ -13,7 +14,7 @@ object HealthCheck { val json: RoutingHttpHandler = routes( "/health" GET { - HealthStatus().ok(jsonLens) + Response(Status.OK).with(jsonLens of HealthStatus()) } ) } diff --git a/invirt-http4k/src/main/kotlin/invirt/http4k/response.kt b/invirt-http4k/src/main/kotlin/invirt/http4k/response.kt index f13e390..eb3956a 100644 --- a/invirt-http4k/src/main/kotlin/invirt/http4k/response.kt +++ b/invirt-http4k/src/main/kotlin/invirt/http4k/response.kt @@ -11,7 +11,6 @@ import org.http4k.lens.BiDiBodyLens import org.http4k.lens.Header import java.time.Instant -fun T.ok(lens: BiDiBodyLens): Response = Response(Status.OK).with(lens of this) fun BiDiBodyLens.ok(message: T): Response = Response(Status.OK).with(this of message) fun Response.withCookies(cookies: Collection): Response { diff --git a/invirt-http4k/src/test/kotlin/invirt/http4k/ResponseTest.kt b/invirt-http4k/src/test/kotlin/invirt/http4k/ResponseTest.kt index bf8c602..e8fdbfb 100644 --- a/invirt-http4k/src/test/kotlin/invirt/http4k/ResponseTest.kt +++ b/invirt-http4k/src/test/kotlin/invirt/http4k/ResponseTest.kt @@ -2,10 +2,7 @@ package invirt.http4k import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe -import org.http4k.core.Method -import org.http4k.core.Request -import org.http4k.core.Response -import org.http4k.core.Status +import org.http4k.core.* import org.http4k.core.cookie.Cookie import org.http4k.kotest.shouldHaveSetCookie import org.http4k.routing.bind @@ -35,22 +32,6 @@ class ResponseTest : StringSpec({ ).bodyString() shouldBe """{"name":"Apache Productions","enabled":true}""" } - "pojo.ok(bidilens)" { - data class JsonTestPojo( - val name: String, - val enabled: Boolean - ) - - val httpHandler = routes( - "/test" bind Method.GET to { - val lens = jsonLens() - JsonTestPojo("Something else in Geordie", true).ok(lens) - } - ) - - httpHandler(Request(Method.GET, "/test")).bodyString() shouldBe """{"name":"Something else in Geordie","enabled":true}""" - } - "withCookies" { val expiry = Instant.now().plusSeconds(30).truncatedTo(ChronoUnit.SECONDS) val response = Response(Status.OK)