Oh! That's because it's
not called with no arguments. If it were called with no arguments, the code would look like:
(GET "/ws" [] (chat-handler))
Instead, the code looks like:
(GET "/ws" [] chat-handler)
We're not calling the function; we're returning it, in the same way as we'd return a value.
The reason it works is because if a function is returned by a route, it's treated as a handler and called with the current request. In other words, the above code is equivalent to:
(GET "/ws" req (chat-handler req))
- James