macchiato-framework / macchiato-core

Ring style HTTP server abstraction for Node.js
MIT License
377 stars 35 forks source link

restful-format middleware can't serialize a root vector #33

Closed denisidoro closed 5 years ago

denisidoro commented 5 years ago

Using the restful-format as highlighted here works for, say:

{:message "hello"}

but not for

[1 2 3]
yogthos commented 5 years ago

The middleware is using the following multimethod to serialize responses, and it's not doing anything special regarding maps and vectors handling. If you could investigate a bit more that would be really helpful, otherwise I'll try take a look when I get a chance.

denisidoro commented 5 years ago

@yogthos, the problem is with deserialize-request, I guess:

cljs.user=> (js->clj (js/JSON.parse "{\"a\": 1}") :keywordize-keys true)
{:a 1}

cljs.user=> (js->clj (js/JSON.parse "[1 2 3]") :keywordize-keys true)
Unexpected number in JSON at position 3
denisidoro commented 5 years ago

Nevermind. The problem was that I wasn't using -H "Accept: application/json" in my curl command