Fork me on GitHub
#luminus
<
2019-09-09
>
holyjak21:09:42

Hello folks! I would very much appreciate an advice on how to programatically test routing and, most of all, content type negotiation and coercion. I have generated a new Luminus app with +service, which uses swagger, retit, muuntaja etc. This is what I am trying to do, in the generated myapp.handler:

(do
    (require '[jsonista.core :as json])
    (import java.io.ByteArrayInputStream)
    ((app)
     {:headers {"accept" "application/json"}
      :uri "/api/employee/start"
      :request-method :post
      #_:query-string
      :body (ByteArrayInputStream.
              (json/write-value-as-bytes
                {:first-name "Bo"}))}))
but it fails with > Request coercion failed ... #:clojure.spec.alpha{:problems ({:path [], :pred clojure.core/map?, :val nil, :via [], :in []}) (my handler expects to get a map) So it seems that the body I am trying to send in is somehow ignored and becomes nil. Any tips? /cc @haakon