This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-23
Channels
- # 100-days-of-code (5)
- # announcements (3)
- # beginners (68)
- # cider (2)
- # cljdoc (2)
- # cljs-dev (10)
- # cljsjs (2)
- # clojure (40)
- # clojure-austin (2)
- # clojure-dev (17)
- # clojure-italy (8)
- # clojure-spec (4)
- # clojure-uk (9)
- # clojurebridge (1)
- # clojurescript (48)
- # datomic (4)
- # emacs (4)
- # figwheel-main (93)
- # fulcro (8)
- # hyperfiddle (33)
- # jobs-discuss (3)
- # luminus (60)
- # off-topic (66)
- # onyx (42)
- # pedestal (11)
- # re-frame (35)
- # reagent (1)
- # reitit (39)
- # shadow-cljs (30)
- # specter (27)
I woulf double-check the imports (`spec-toold.data-spec :as ds`) and try lein clean
or similar to flush the possible dirty state.
it's still validating the parameter definitions with kw-map? which fails for ds/opt
made a commit that reproduces it https://github.com/valerauko/kitsune/tree/repro-145
but when i copy-paste the code in the readme it throws a null pointer exception at me
kitsune.core=> (require '[muuntaja.core :as muuntaja])
nil
kitsune.core=> (def m
#_=> (muuntaja/create
#_=> (-> muuntaja/default-options
#_=> (assoc-in [:formats "application/json" :matches] #"^application/(.+\+)?json$"))))
#'kitsune.core/m
kitsune.core=> ((:negotiate-content-type m) "application/activity+json")
NullPointerException kitsune.core/eval32703 (form-init6274978273947769720.clj:1)
seems :negotiate-content-type is missing?
kitsune.core=> (:negotiate-content-type m)
nil
it should be able to parse post request bodies that come with content type #{"application/json" "application/activity+json" "application/ld+json"}
https://github.com/metosin/muuntaja/blob/master/doc/Configuration.md#loose-matching-on-content-type
Here the test: https://github.com/metosin/muuntaja/blob/70cf9792b6cbf1f39936da44a4208924b48931fb/test/muuntaja/middleware_test.clj#L105-L109
i thought making an instance with muuntaja/create
(with options) and mounting taht on the routes under :data :muuntaja
was the way
when the header is "content-type" "application/activity+json"
, :body
comes through as a java.io.ByteArrayInputStream
if you can isolate a minimalistic failing example config/code to run in repl, I can look in the evening.
also with the body-params specced as string? coercion kept 400ing, only works with any?
(muuntaja/create
(-> muuntaja/default-options
(assoc-in [:formats "application/json" :matches]
#"^application/(.+\+)?json$")
(assoc-in [:formats "application/xml" :matches]
#"^application/(.+\+)?xml$")))
why is this telling me application/xml is invalid?is there a way to just pass it through like plain text strings (charset encoded) and i'll handle the rest?
To get raw xml, just do not register the format and read the raw format from request. There is m/get-request-format-and-charset
to help.
(require '[muuntaja.middleware :as middleware])
(require '[muuntaja.core :as m])
(->> {:headers {"content-type" "application/edn; charset=utf-16"
"accept" "cheese/cake"
"accept-charset" "cheese-16"}}
((middleware/wrap-format identity))
((juxt m/get-request-format-and-charset
m/get-response-format-and-charset)))
;[#FormatAndCharset{:format "application/edn"
; :charset "utf-16"
; :raw-format "application/edn"}
; #FormatAndCharset{:format "application/json"
; :charset "utf-8"
; :raw-format "cheese/cake"}]