Andrew O'Hara
08/06/2024, 9:11 PMhttp4k-testing-chaos
, I wanted to override a specific route to return a specific response. I ended up with this:
api.misbehave(object: Behaviour() {
override fun invoke(next: HttpHandler) = routes(
"/route/to/override" bind Method.GET to {
Response(Status.OK).body("Actually an error")
},
{ _: Request -> true }.asRouter() bind next
)
})
I didn't love how:
• There's wasn't a pre-existing ChaosBehaviours
for ReturnResponse
• I had to manually add a wildcard router to have the remainder of requests go to to the original HttpHandler
Are there better ways I could have done this? Or are these potential features for the chaos module?