joaotavora / snooze

Common Lisp RESTful web development
207 stars 22 forks source link

clack backend payload #37

Open boogsbunny opened 4 months ago

boogsbunny commented 4 months ago

Hey, I'm having issues with JSON parsing.

I run into this issue when using clack as the backend:

Callback Error: the message-complete callback failed
  The value
    NIL
  is not of type
    VECTOR
  when binding WOO.EV.SOCKET::DATA
   [Condition of type FAST-HTTP.ERROR:CB-MESSAGE-COMPLETE]

Here's the route:

(defroute foo (:post :application/json)
  (let* ((json (handler-case
                   (cl-json:decode-json-from-string
                    (payload-as-string))
                 (error (e)
                   (http-condition 400 "Malformed JSON (~a)!" e)))))))

and the JSON passed in is just {"user": "hi"}. It seems that read-sequence fails when wanting to read the raw body from clack.