luminus

Brandon Olivier 2019-06-21T03:56:42.043600Z

I'm trying to return json from a request in luminus, but I keep getting an error like java.lang.IllegalStateException: Can't coerce body of type class clojure.lang.PersistentArrayMap

Brandon Olivier 2019-06-21T03:57:00.044Z

but the body type is a string, not a persistent array map (I don't think)

Brandon Olivier 2019-06-21T03:57:22.044400Z

I added these routes to the main route handler that comes configured

(defn about [request]
  (->  "{\"foo\": \"bar\"}"
       (response/ok)
      (response/header "Content-Type" "application/json")))

(defn api-routes []
  ["/api"
   {:middleware []}
   ["/about" {:get about}]])

Brandon Olivier 2019-06-21T04:01:16.045Z

When I hit the endpoint, I get a 500 response, and the Content-Type is octet-stream instead of json

yogthos 2019-06-21T12:25:51.045100Z

the forums uses to support their own custom markdown that used ~~~ instead of the triple backtick

yogthos 2019-06-21T12:29:05.046400Z

the coercions should be handled by the middleware automatically, so you should just be able to return (response/ok {:foo :bar})

jcb 2019-06-21T16:26:53.048700Z

apologies for the basic question - in Luminus (or clojurescript) is there anything built-in for creating a list of files in a folder in the resources directory? Or should I reach for a npm library? thanks!