Herwig,
Thanks for the detailed answers below.
(def my-app (app
wrap-stacktrace
(wrap-file "resources/public/")
[page] (-> (chrome page) response constantly)
["a" "b"] (-> "a b" response constantly))
[&] (-> "Nothing was found" response (status 404) constantly)))
I have added another route /a/b, which also returns "Nothing was found"
instead of "a b" ?
2012/9/7 Murtaza Husain <[email protected]>
>
> (def my-app (app
> wrap-stacktrace
> (wrap-file "resources/public/")
> [page] (-> (chrome page) response constantly)
> [&] "Nothing was found"))
>
> I am getting a null pointer error on the route "/". Why is that ? Shouldnt
> it give a 404 or something. Also why isnt it caught by the last route [&] ?
>
Hi Murtaza,
moustache handlers must be functions. So to return a string as a response,
the last line would have to be
[&] (constantly "Nothing was found")
That however still wouldn't do what you expect, because the value returned
from a handler has to be a response map like
[&] (constantly {:status 404 :body "Nothing was found"})
or
[&] (-> "Nothing was found" response (status 404) constantly)
The auto response wrapping, that allows you to just return strings, is a
convenience feature living in compojure, not ring.
If that resolves your problem, please consider reposting to the list, so
that others may benefit.
kind regards
On Friday, September 7, 2012 4:18:28 PM UTC+5:30, Herwig Hochleitner wrote:
>
> In my experience, ring responds with 500 on error.
> You can use ring.middleware.stacktrace to make the error show up in the
> browser.
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en