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

API for modifying default cljs-http.client/request middleware? #79

Open
pandeiro opened this issue Oct 29, 2015 · 2 comments
Open

API for modifying default cljs-http.client/request middleware? #79

pandeiro opened this issue Oct 29, 2015 · 2 comments

Comments

@pandeiro
Copy link

I have a use-case like this: I need to talk JSON but there are keys in the third-party JSON payloads which are not keywordizable.

Currently (I think) this means that I can't use the niceties of the cljs-http.client namespace, which I was using extensively, because :keywordize-keys true is baked in to the json-response middleware included there.

Would it be possible / practical / a good thing for users to be able to somehow modify this default middleware? So that, for instance, I could do something like this:

(swap! cljs-http.client/*default-middleware* (partial remove (set cljs-http.client/wrap-json-response)))

Or is that a terrible idea? Thanks for listening!

@r0man
Copy link
Owner

r0man commented Oct 29, 2015

Hi Murphy,
I think the best way would be to make this configurable as a parameter to
wrap-json-response and then build your own client with the stuff you need.
I am aware that the get/post etc fns are tied to the default client. I
think those fns should be changed so you can pass a client as the first
parameter. Because of that I usually just call the request fn and use a map
as arguments, and don't use those fns at all. It's a bit of a relict trying
to have the same api as clj-http. I would like to improve this in the
future. Unfortunately I'm on a surf trip at the moment and AFK most of the
time. If you can send a PR with the changes to wrap-json-response I would
merge that.
Roman
On 29 Oct 2015 4:53 p.m., "Murphy McMahon" [email protected] wrote:

I have a use-case like this: I need to talk JSON but there are keys in the
third-party JSON payloads which are not keywordizable.

Currently (I think) this means that I can't use the niceties of the
cljs-http.client namespace, which I was using extensively, because :keywordize-keys
true is baked in to the json-response middleware included there.

Would it be possible / practical / a good thing for users to be able to
somehow modify this default middleware? So that, for instance, I could do
something like this:

(swap! cljs-http.client/default-middleware (partial remove (set cljs-http.client/wrap-json-response)))

Or is that a terrible idea? Thanks for listening!


Reply to this email directly or view it on GitHub
#79.

@pandeiro
Copy link
Author

Roman! That's not unfortunate at all -- that is great! Enjoy the waves!

Anyhow yes I see your point, and I will send a PR for review soon.

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