# Combine \`HTTP.Response\` to \`HTTP.Stream\` handlers within one server in HTTP.jl

**URL:** <https://discourse.julialang.org/t/combine-http-response-to-http-stream-handlers-within-one-server-in-http-jl/93985>\
**Category:** General Usage\
**Tags:** web, http\
**Created:** [February 3, 2023, 12:09pm UTC](https://discourse.julialang.org/t/combine-http-response-to-http-stream-handlers-within-one-server-in-http-jl/93985 "2023-02-03T12:09:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sairus7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sairus7/32/10816_2.png) [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Post date:** [February 3, 2023, 12:09pm UTC](https://discourse.julialang.org/t/combine-http-response-to-http-stream-handlers-within-one-server-in-http-jl/93985/1 "2023-02-03T12:09:03Z")

</div>

What is the replacement for [`HTTP.Handlers.StreamHandlerFunction`](https://juliaweb.github.io/HTTP.jl/v0.9/public_interface/#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`:

```julia
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:

```julia
HTTP.@register(ROUTER, "GET", "/another_function", another_function |> JSONMiddleware |> CorsMiddleware |> HTTP.streamhandler)

```

---

<div class="post-metadata">

**Author:** ![quinnj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/quinnj/32/11_2.png) [@quinnj](https://discourse.julialang.org/u/quinnj)\
**Post date:** [February 4, 2023, 3:58am UTC](https://discourse.julialang.org/t/combine-http-response-to-http-stream-handlers-within-one-server-in-http-jl/93985/2 "2023-02-04T03:58:00Z")

</div>

Posted an answer to this in slack: [Slack](https://julialang.slack.com/archives/C683N3423/p1675447915134639?thread_ts=1675423082.551789&cid=C683N3423)
