Skip to content

Latest commit

 

History

History
53 lines (39 loc) · 1.58 KB

README.md

File metadata and controls

53 lines (39 loc) · 1.58 KB

Clojars Project

Duct Reitit

A Duct component that uses Reitit as the router for your application.

Installation

To install, add the following to your project :dependencies:

[nl.mediquest/duct.module.reitit "1.0.5"]

Usage

To use this router, add the :duct.router/reitit key and reference it from :duct.core/handler to use it.

{:duct.profile/base
 {:duct.core/project-ns my-app
  :duct.handler/root
  {:router #ig/ref :duct.router/reitit}
  :duct.router/reitit
  {:routes ["/" {:handler #ig/ref :my-app.handler/index
                 :middleware [#ig/ref :my-app.middleware/example]}]
   :reitit.ring/opts { ;; Add extra opts to be passed in to reitit.ring/router
                      }
   :retit.ring/default-handlers { ;; Optionally overwrite the default handlers
                                 }}
  :my-app.handler/index {}
  :my-app.middleware/example {}}}

See the route syntax section of Reitit's documentation for more information on the format it expects.

Reitit will assoc the router in the request by default. This is useful for if you need to generate the path for a given route name.

(require '[reitit.core :as reitit])

(defn my-handler [{::reitit/keys [router]}]
  (:path (reitit/match-by-name router :user/show {:id 1}))
  ;; => "/users/1"
  )