duct

Matheus Moreira 2021-03-16T10:54:25.004Z

Hello! What is the correct way of setting up a duct + reitit project? Currently, I have the following:

{:duct.profile/base
 {:duct.core/project-ns patrulleros.fixtures.directory}

 :duct.profile/dev #duct/include "dev"
 :duct.profile/local #duct/include "local"
 :duct.profile/prod {}

 :duct.module/logging {}
 :duct.module/web {}

 :patrulleros.fixtures.directory.api/router {}}
:patrulleros.fixtures.directory.api/router inherits from :duct/router. This key is initiated like this:
(def routes
  [["/swagger.json"
    {:get {:no-doc true
           :swagger {:info {:title "A Title"}}
           :handler (reitit.swagger/create-swagger-handler)}}]])

(defn router []
  (reitit.ring/router
   routes
   {:exception reitit.dev.pretty/exception
    :data {:coercion reitit.coercion.malli/coercion
           :muuntaja (muuntaja/create
                      (assoc-in (muuntaja/select-formats muuntaja/default-options ["application/json"])
                                [:formats "application/json" :opts]
                                {:mapper (-> (jsonista/object-mapper)
                                             (.setSerializationInclusion JsonInclude$Include/NON_EMPTY))}))
           :middleware [reitit.swagger/swagger-feature
                        reitit.ring.middleware.parameters/parameters-middleware
                        reitit.ring.middleware.muuntaja/format-negotiate-middleware
                        reitit.ring.middleware.muuntaja/format-response-middleware
                        ;; exception-middleware
                        reitit.ring.middleware.muuntaja/format-request-middleware
                        reitit.ring.coercion/coerce-response-middleware
                        reitit.ring.coercion/coerce-request-middleware]}}))

(defmethod integrant/init-key ::router [_ _]
  (reitit.ring/ring-handler
   (router)
   (reitit.ring/routes
    (reitit.swagger-ui/create-swagger-ui-handler {:path "/"})
    (reitit.ring/create-default-handler))))
Starting the system results in a NPE inside reitit.ring$_create_file_or_resource_handler. How should I define my configurations?

kwrooijen 2021-03-16T11:55:18.004100Z

Here is a very simple duct example with Reitit. Check the config.edn file https://github.com/kwrooijen/duct-simple-example