Fork me on GitHub

the reitit-http (a.k.a the interceptor module) syntax about to freeze. the ring-handler will take an mandatory options map, which must have an :executor key and can have optionally :interceptors (that are queued for all routes, including the default branch). :executor should satisfy:

(defprotocol Executor
    [this interceptors]
    "takes a sequence of interceptors and compiles them to queue for the executor")
    [this interceptors request]
    [this interceptors request respond raise]
    "executes the interceptor chain"))


here’s a minimal example app with few dummy interceptors:

(ns example.server
  (:require [reitit.http :as http]
            [reitit.ring :as ring]
            [ring.adapter.jetty :as jetty]))

(def app
       {:interceptors [{:enter identity}]}

       ["/hello" {:get (fn [request]
                         {:status 200
                          :body "hello!"})}]])
    {:executor reitit.interceptor.sieppari/executor
     :interceptors [{:enter identity}]}))

(defn start []
  (jetty/run-jetty #'app {:port 3000, :join? false, :async? true})
  (println "server running in port 3000"))



will try to cook up a pedestal sample.


it builds on top of reitit-ring, so all handlers (swagger, swagger-ui, default-handler, resource-handler etc) work, only difference is that middleware is replaced with interceptors. The default middleware need to be ported into interceptors at some point.