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

Control Content-Type header #43

Closed
dustingetz opened this issue Jan 6, 2015 · 1 comment
Closed

Control Content-Type header #43

dustingetz opened this issue Jan 6, 2015 · 1 comment

Comments

@dustingetz
Copy link

I would like to be able to control the "Content-Type" header.

It would also be nice if I could put all my data in the request :body and have cljs-http serialize it based on my provided content-type, rather than have to put my data in the proper magic key (:edn-params, :transit-params etc).

This would also pave a path to making it easier to configure cljs-http serialization from the app, something like this (this is clojure/pedestal code not cljs)

(def content-types
  {"application/json;charset=UTF-8"
   (fn [body]
     (print-fn #(http/json-print body)))

   "application/edn;charset=UTF-8"
   (fn [body]
     (print-fn #(pr body)))

   "application/transit+json;charset=UTF-8"
   (fn [body]
     (fn [^OutputStream output-stream]
       (transit/write (transit/writer output-stream :json-verbose) body)
       (.flush output-stream)))

   "application/transit+msgpack;charset=UTF-8"
   (fn [body]
     (fn [^OutputStream output-stream]
       (transit/write (transit/writer output-stream :msgpack) body)
       (.flush output-stream)))

   })
@dustingetz
Copy link
Author

It appears I can control the content-type header after all, I'm not sure why I didn't see that befor

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

1 participant