I'm upgrading from 4.48.0.0 to 5.6.5.0 and I've hi...
# http4k
s
I'm upgrading from 4.48.0.0 to 5.6.5.0 and I've hit a problem with my Sse consumer, as I can't find any example of how to cope with the removal of connectRequest from the Sse interface. I have code that looks like this
Copy code
class EngineSseConsumer(
    private val engineClient: ApplicationClient,
    private val forwardAuth: ForwardAuthorization,
    private val consumers: List<Consumer<Event>>,
) : SseConsumer {
    override fun invoke(sse: Sse) {
        val auth = forwardAuth.forward(sse.connectRequest)

        engineClient.notifications(-1, auth).forEach { n ->
            consumers.forEach { it.accept(Event(n, auth)) }
        }
    }
The function
forwardAuth.forward
is stripping the Bearer token out of the incoming request and wrapping it so it can be forwarded to a backend service. The routing looks like this
Copy code
fun sseRoutes(
    engineClient: ApplicationClient,
    forwardAuth: ForwardAuthorization,
): RoutingSseHandler =
    sse(
        "/iou/sse" bind EngineSseConsumer(
            engineClient,
            forwardAuth,
            listOf(
                IouCompleteEventConsumer(engineClient),
                PaymentEventConsumer(engineClient),
            ),
        ),
    )
I can always recreate the previous situation by extending the interface, but I'm sure there's a better way, perhaps with the use of a filter, but I'm having trouble getting my head around that.
d
you're right. It seems like that has been undone during the rewrite of the WS and SSE. I think we can put if back with no problems (we already have the request when creating the SSE
bear with us and I'll take a closer look soon.
s
Thanks, no big rush, but does look like the baby went out with the bath water
d
Sorry about that - I do remember removing it, but it was because we didn't need it any more and I failed to consider that it would be handy to have access to it. It doesn't break the model so it should be ok. 🙂
a
The WS changes took me by surprise, but very happy to see it seems like I can reject a WS upgrade request now.
d
yeah - overall the model is better (and more consistent with everything else 🙂 )