Hi, i’m using Spring Webflux and trying to add some logging around each response by using a ServerHt...
m
Hi, i’m using Spring Webflux and trying to add some logging around each response by using a ServerHttpResponseDecorator. The responses are coming back fine via postman, however I’ve noticed I can no longer load my swagger UI (just get a blank white screen). Anyone know why? Code in thread
stackoverflow 1
This doesn’t work:
Copy code
class ResponseLoggingDecorator(
    delegate: ServerHttpResponse
) : ServerHttpResponseDecorator(delegate) {

    override fun writeWith(body: Publisher<out DataBuffer>): Mono<Void> {
        val buffer = Mono.from(body)

        return super.writeWith(buffer.doOnNext { dataBuffer: DataBuffer ->
        })
    }
}
But this does work (swagger UI loads), a bit obvious but shows something is wrong with the doOnNext?
Copy code
class ResponseLoggingDecorator(
    delegate: ServerHttpResponse
) : ServerHttpResponseDecorator(delegate) {

    override fun writeWith(body: Publisher<out DataBuffer>): Mono<Void> {
        return super.writeWith(body)
    }
}
m
As has been suggested by reactions, not Kotlin specific. Hence Stack Overflow et al (there's also Gitter chats for various Spring projects, the spring boot one is very active) are better places to ask.
m
Aye realised that, no worries. If anyone does search for this, then the reason was it should be
.toFlux()
not
.toMono()
👍 1