Thanks for the insight. I am indeed using Compojure for routing and wasn't
aware it returns nil by default. For reference, here is the
wrapped-sync-app function along with sync-app which is used to render a
response from the chat page:
(defn sync-app [request]
{:status 200
:headers {"content-type" "text/html"}
:body (page)})
(def wrapped-sync-app
"Wraps the response with static files"
(-> sync-app
(wrap-resource "public")
(wrap-file-info)))Enter code here...
On Sunday, March 6, 2016 at 7:01:17 AM UTC-6, red...@gmail.com wrote:
>
> On 03/05/2016 10:18 PM, Nasko wrote:
> > I am trying to implement a simple asynchronous chat service using Aleph
> > and Lamina. However, it looks like the enqueue function coming from
> > lamina cannot be implemented and causes an exception. This is what my
> > chat function looks like:
> > |
> > (defn chat [ch request]
> > "View handler that handles a chat room. If it's not
> > a websocket request then return a rendered html response."
> > (let [params(:route-paramsrequest)
> > room (:room params)]
> > (if(:websocket request)
> > (chat-handler ch room)
> > (enqueue ch (wrapped-sync-app request)
> > |
> > I don't understand why the value of (wrapped-sync-app request) is nil.
> > Any feedback would be helpful.
>
> Hard to say, since you don't give a definition for the wrapped-sync-app
> function. Some google and it shows up in a few example apps as some kind
> of ring handler. If you are using compojure (maybe other routing
> libraries) returning nil is what it does by default if no routes match a
> give request (as a result of how it determines if a route matches).
>
> But looking at your subject line, given that error it is likely 'ch' is
> nil, not the result of calling wrapped-sync-app. I would sprinkle
> printlns liberally throughout.
>
> As an aside, your docstring (if you intend it to be a docstring) is in
> the wrong place. Docstrings go before the argument vector if you want
> them to be accessible via 'doc' in the repl.
> https://github.com/jonase/eastwood has a linter that catches this kind
> of thing.
>
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clo...@googlegroups.com
>
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+u...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to clojure+u...@googlegroups.com
> > <mailto:clojure+u...@googlegroups.com >.
> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
> And what is good, Phaedrus,
> And what is not good—
> Need we ask anyone to tell us these things?
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.