Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retain original handler result in metadata. #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xsc
Copy link

@xsc xsc commented Mar 3, 2015

Summary

This MR would add the key :liberator/value - containing the original/raw value - to responses generated by run-handler.

Reason

To be able to verify response bodies (e.g. against a schema) one currently has to decode the content-negotiated-and-then-encoded data that Liberator resources produce (which is neither pretty nor always easily feasible). Alternatively, one can use ring-response to override the body, resulting in losing the value that the content negotiation provides.

Performing verification on the raw value seems reasonable and could be facilitated using the proposed changes.

@xsc
Copy link
Author

xsc commented Mar 3, 2015

Actually, retaining values not only for ring-response might be desirable. Let me know what you think.

@ordnungswidrig
Copy link
Member

I like the general idea but I have two things to add:

  • why not putting the "value" into the response map at :liberator/value instead of the meta-data. I think it would be more accessible. However there might my drawback because it's always "visible", e.g. when logging the response etc.
  • the add the value only for RingResponse. I think we should enable this for every value that is returned from a handler. I.e. associate the original value to the response (or response meta) in run-handler.

@xsc xsc force-pushed the ys/ring-response-value branch from f44ddc8 to f21a252 Compare March 3, 2015 16:38
@xsc
Copy link
Author

xsc commented Mar 3, 2015

I pushed an alternative approach as f21a252, attaching the raw value to every response in run-handler, albeit still in the metadata since it would cause tests to fail otherwise. I can move it into the response map itself but I'm not sure whether this information is useful enough to warrant that.

On another note: Is :liberator/value the right name for this? Also, I'm not sure where a test for this would belong, so I'd be glad for any pointers. :)

@xsc xsc changed the title when using ' ring-response', retain original value in metadata. retain original handler result in metadata. Mar 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants