Fork me on GitHub
#reitit
<
2018-09-24
>
valerauko00:09:24

won't that 400 if i have query parameter coercion?

valerauko00:09:10

if i make a format mimicking the code of the muuntaja built-ins that should work as expected right? eg https://github.com/metosin/muuntaja/blob/master/modules/muuntaja/src/muuntaja/format/edn.clj

ikitommi05:09:28

true that, if you have coercion, you need to parse the format before it. EDN-format is a good example of an simple format.

valerauko08:09:04

all right gonna make a plaintext format for xml/html/plaintext

valerauko09:09:16

i had this function for byte array input stream -> string

(defn bais->bytes
  [^java.io.ByteArrayInputStream bais]
  (.reset bais)
  (let [av (.available bais)
        bs (byte-array av)]
    (.read bais bs 0 av)
    (String. bs "UTF-8")))
i'm not familiar with the properties of that object, i made it based on simple trial and error. is it safe(r) to use the inputstreamreader -> pushbackreader way i see in your edn format?

ikitommi18:09:06

EDN requires a pushbackreader, no other reason for it.

👍 4
valerauko13:09:27

all right made a basic plaintext one that can be parameterized for any content type that should be handled as plain text

(defn format
  ([] (format "application/xml"))
  ([content-type]
    (core/map->Format
      {:name content-type
       :matches [(re-pattern
                   (clojure.string/replace-first content-type "/" "/(.+\\+)"))]
       :decoder [decoder]
       :encoder [encoder]})))

ikitommi18:09:47

[metosin/reitit "0.2.3"] is out with default OPTIONS endpoints generated for all paths (to better support CORS), parameter-middleware fix & updated deps. Changelog: https://github.com/metosin/reitit/blob/master/CHANGELOG.md#023-2018-09-24

🎉 8