What is the replacement for HTTP.Handlers.StreamHandlerFunction
in post 1.0 HTTP.jl package?
I have a server that handles requests, but with a single endpoint with streaming HTTP connection, in 0.9 I could just write the following to switch from HTTP.Response
to HTTP.Stream
:
function my_run(io::HTTP.Stream)
startwrite(io)
write(io, "hello")
...
closewrite(io)
end
HTTP.@register(ROUTER, "GET", "/run", HTTP.StreamHandlerFunction(my_run))
In latest version I see just streamhandler
that does the opposite: transforms HTTP.Response
to HTTP.Stream
.
UPD: Found an ugly solution - serve with stream
flag set, make a router handler the first one in middleware sequence, and past the full sequence at every request endpoint, starting with streamhandler, like here:
HTTP.@register(ROUTER, "GET", "/another_function", another_function |> JSONMiddleware |> CorsMiddleware |> HTTP.streamhandler)