clojurewebsocketaleph

Aleph/Clojure - How to insert custom headers in the web socket upgrade response?


I am trying to port one of our services to Aleph. The service uses a web socket server (currently runs on http-kit). One of the things I require is the ability to add some custom http headers in the response during the websocket Upgrade process. Do you see a way I could do that?

To elaborate, I need to inspect the Sec-WebSocket-Extensions header value from the client request, and based on that add a response header during the upgrade process. And similarly need to check the Sec-WebSocket-Protocol header in the request, and add the same back to the response if the protocol is what I expect.


Solution

  • Both websocket-connection & websocket-client accepts a :headers keywords parameter. The documentation is here.