Works by default with Muuntaja

This commit is contained in:
Tommi Reiman 2018-07-16 15:57:12 +03:00
parent 346fbad775
commit 0f03d0786c
2 changed files with 3 additions and 10 deletions

View file

@ -4,15 +4,11 @@
[reitit.middleware :as middleware]
[reitit.ring.coercion :as rrc]))
;; unlift Middleware Record into vanilla Ring middlewareL
;; NOTE: to support format-based body coercion, an options map needs
;; to be set with :extract-request-format and extract-response-format
;; unlift Middleware Record into vanilla Ring middleware
(defn wrap-coercion [handler resource]
(middleware/chain
[rrc/coerce-exceptions-middleware
rrc/coerce-request-middleware
rrc/coerce-response-middleware]
handler
resource
{:extract-request-format (comp :format :muuntaja/request)
:extract-response-format (comp :format :muuntaja/response)}))
resource))

View file

@ -69,10 +69,7 @@
"application/transit+json"}
:consumes #{"application/json"
"application/edn"
"application/transit+json"}}}
;; TODO: these should work by default!
:extract-request-format (comp :format :muuntaja/request)
:extract-response-format (comp :format :muuntaja/response)})
"application/transit+json"}}}})
(ring/routes
(swagger-ui/create-swagger-ui-handler
{:path "/", :url "/api/swagger.json"})