I was hoping for Muuntaja to be a simple drop-in replacement for ring.middleware wrap-formats, but it has been a week of running my head into apparent dependency errors. Even when I trace through lein deps :tree
to remove dependencies with old versions of jsonista, my errors don’t seem to go away. Here’s the error:
error in process sentinel: Could not start nREPL server: Exception in thread “main” java.lang.ExceptionInInitializerError at clojure.main.(main.java:20)
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/exc/InputCoercionException, compiling:(jsonista/core.clj:79:38)
In the new-project case in which I can actually get the repl to start, shortly after I try to evaluate my Muuntaja buffers I start getting “no REPL connected” errors.
(ns hmeg.middleware
(:require [muuntaja.middleware :refer [wrap-format wrap-params]]))
;; ... other stuff ...
(defn wrap-formats [handler]
(let [wrapped (-> handler wrap-params wrap-format)]
(fn [request]
((if (:websocket? request) handler wrapped) request))))
;;;;;;;;;;;;;;;;;;
(ns hmeg.handler
(:require [compojure.core :refer [routes wrap-routes]]
[hmeg.layout :refer [error-page]]
[hmeg.routes.home :refer [home-routes]]
[hmeg.routes.admin :as admin]
[compojure.route :as route]
[ring.util.http-response :as response]
[ring.middleware.format-params :as mformat]
[hmeg.env :refer [defaults]]
[mount.core :as mount]
[hmeg.middleware :as middleware]))
(defn app-routes []
(routes
(-> #'home-routes
(wrap-routes middleware/wrap-formats))
(-> #'admin/routes
(wrap-routes middleware/wrap-formats))
(route/not-found
(:body
(error-page {:status 404
:title "page not found"})))))
(defn app [] (middleware/wrap-base (app-routes)))
Any ideas?