Fork me on GitHub
#yada
<
2015-11-10
>
imre09:11:53

I'm looking to expose the usecases of a business logic library as resources, in the first run this would mean mostly GET and POST requests being mapped to functions returning data

imre09:11:58

GETs are fine but POSTs are giving me pain

imre09:11:24

has anyone had experience mapping posts to function calls?

imre13:11:10

the problem I'm having is with returning a map from such a function call, something like

{:errors [:email-invalid}

imre13:11:37

"No implementation of method: :interpret-post-result of protocol: #'yada.methods/PostResult found for class: clojure.lang.PersistentArrayMap" when I wrap my response in a record that implements that protocol, I get a low-level conversion error saying "Don't know how to convert class ... into (stream-of io.netty.buffer.ByteBuf)"

mccraigmccraig13:11:59

@malcolmsparks: i'm on a slightly forked -9 atm... are there any significant api changes between there and HEAD ?

mccraigmccraig13:11:24

hi imre, here's an example of a resource returning a JSON object from a POST request - https://www.refheap.com/76f1fa00254c4e91244e2cf9c - the salient bit being that it's actually returning a string which has been encoded with cheshire/generate-string

imre13:11:36

thanks very much for that, checking now

imre13:11:43

I'm wondering how to utilize the multi-content-type feature of yada there, I take it you haven't found a solution to that yourself?

imre13:11:25

like when you do

(yada {:foo :bar})
it will be represented as per negotiated with the client

mccraigmccraig13:11:09

oh, i haven't true @imre - this app doesn't care - it's just JSON

imre13:11:53

never mind, thanks for the suggestion though, I'm going through it now

mccraigmccraig13:11:28

@imre: you can ignore the with-context/mlet/return stuff ... that's async handling ... it should work just the same if you strip it out and go synchronous

imre16:11:12

I seem to have managed to hack my way through what yada does there

imre16:11:25

impressive codebase, I have to admit

imre17:11:08

here's what I came up with in case anyone has similar problems: https://gist.github.com/imrekoszo/44671357f415b05f2c49