macchiato-framework / macchiato-core

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

added utils for json responses #15

Closed facundoolano closed 7 years ago

facundoolano commented 7 years ago

This adds json and sorted-json to macchiato.util.responses. I've found those functions handy when dealing with JSON API handlers.

yogthos commented 7 years ago

Might make sense to add transit as well, as EDN is pretty common for Clojure client/server communication.

yogthos commented 7 years ago

excellent, I'll push out the new version

facundoolano commented 7 years ago

cool!

yogthos commented 7 years ago

@facundoolano Also, I completely forgot to mention the restful-format middleware is probably the best way to handle encoding/decoding in most situations. It attempts to figure out the content type based on the header, and encodes the response based on the accept types provided. I haven't had a chance to test it too much yet, but if you can take it for a spin that would be great. :)

facundoolano commented 7 years ago

Yeah, I've tried it when I was just starting out with my experiments, and it didn't work exactly as I needed at the time (I don't exactly remember what it was, I think that it had to do with it not parsing the body if there wasn't an accept header present). I should probably revisit now that I have a better idea of how the pieces fit together.

yogthos commented 7 years ago

Yeah, I definitely don't rule out bugs there either. I'm just starting to make an API in a project at work, so I'll end up dogfooding it shortly. :)