Fork me on GitHub
#pedestal
<
2023-04-03
>
Chris Lester06:04:47

I am trying to get SSE events working for the first time, and am encountering an error around content types I could use help with:

No matching content-type available {:supported-content-types #{application/json application/transit+msgpack application/transit+json application/edn}, :available-content-types (multipart/form-data), :header Accept}
I'm unsure how to inform Pedestal this is a text/event-stream or get it to be "happy" .. but setting the content type in a header doesn't seem to work. I.e., returning this from the (sse/start-event-stream ..) stream-ready fn.
{:body (stream-events response event-chan) ;; fixed one bug where those were reversed, did not help.
        :headers {"Content-Type" "text/event-stream"}}
Stream-events is simple, takes a source chan and feeds it to the target chan:
(defn stream-events [source sink]
  (async/go
    (loop []
      (let [event (async/<! source)]
        (when (not= :done event)
          (async/>! sink event)
          (recur))))))

hlship15:04:56

There's no chance you are attempting to stream a nil? core.async treats nil as roughly "this channel has closed".

Chris Lester18:04:05

It's possible I suppose, although I get a response from the same code in the repl. I'll add some logging to track that possibility.

Chris Lester18:04:39

Ofc, in the repl I'm not going through pedestals full stack. I haven't spent time to figure out how to get that working yet.

Chris Lester19:04:55

Yep, that is what's happening. Will chase that down. Thx!