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

Provide utility functions for use as arg-key-fn in vcr-clj.clj-http/with-cassette #17

Open
chairmank opened this issue Mar 3, 2017 · 1 comment

Comments

@chairmank
Copy link
Contributor

The default arg-key-fn in vcr-clj.clj-http/with-casette is an anonymous function

(fn [req#] (select-keys req# default-req-keys))

Users would benefit from having access to this function as a public default-arg-key-fn var in this namespace, which they can use as a building block for their own customized key functions.

Often, users want to test that the paylod of a HTTP request satisfies an expectation. This is a common enough use case, and the implementation is tricky enough, that vcr-clj.clj-http ought to expose another built-in key function that serializes the body of the request (if one is present). If reading the body is a destructive operation, this function needs to replace the body with a fascimile that resembles the original, unread body.

@gfredericks
Copy link
Owner

I've at least moved out the default-arg-key-fn for now. The rest of this is not trivial, so I won't be tackling it today at least. But it's definitely a good idea.

chairmank added a commit to chairmank/vcr-clj that referenced this issue Apr 14, 2017
I added a new `:arg-transformer` option that is analogous to the existing
`:return-transformer` option. During both recording and playback, the original
arguments are interepted and replaced by `(apply return-transformer args)`, and
these transformed arguments are passed to `arg-key-fn`, `recordable?`, and the
recorded function.

This feature is intended to enable serialization of HTTP request bodies for
gfredericks#17
chairmank added a commit to chairmank/vcr-clj that referenced this issue Apr 17, 2017
I added a new `:arg-transformer` option that is analogous to the existing
`:return-transformer` option. During both recording and playback, the original
arguments are intercepted and replaced by `(apply return-transformer args)`,
and these transformed arguments are passed to `arg-key-fn`, `recordable?`, and
the recorded function.

This feature is intended to enable serialization of HTTP request bodies for
gfredericks#17
chairmank added a commit to chairmank/vcr-clj that referenced this issue Apr 17, 2017
I added a new `:arg-transformer` option that is analogous to the existing
`:return-transformer` option. During both recording and playback, the original
arguments are intercepted and replaced by `(apply return-transformer args)`,
and these transformed arguments are passed to `arg-key-fn`, `recordable?`, and
the recorded function.

This feature is intended to enable serialization of HTTP request bodies for
gfredericks#17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants