Andrew O'Hara
10/12/2021, 8:26 PMOPTIONS
call. The call works fine with a core http4k router, but if I wrap it in a contract
, then the contract router never calls my handler and returns an empty 200. Presumably, this was done with the assumption that OPTIONS
doesn't make much sense in a RESTP API, but that isn't always the case.
Is this phenomenon intentional? Is there a way to prevent it?
@Test
fun options() {
val handler = contract {
routes += "/v1/things" bindContract Method.OPTIONS to { _ ->
Response(Status.OK).body("lolcats")
}
}
val resp = handler(Request(Method.OPTIONS, "/v1/things"))
resp shouldHaveStatus Status.OK
resp shouldHaveBody "lolcats"
}
Body: expected:<"lolcats"> but was:<<empty string>>
dave
10/13/2021, 6:31 AMAndrew O'Hara
10/13/2021, 2:35 PM