This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-20
Channels
- # announcements (1)
- # bangalore-clj (27)
- # beginners (82)
- # boot (4)
- # chestnut (1)
- # cider (22)
- # cljs-dev (26)
- # cljsrn (4)
- # clojure (118)
- # clojure-dev (18)
- # clojure-italy (2)
- # clojure-losangeles (1)
- # clojure-nl (2)
- # clojure-russia (1)
- # clojure-spec (15)
- # clojure-uk (125)
- # clojurescript (61)
- # core-async (74)
- # cursive (2)
- # datomic (41)
- # duct (6)
- # editors (7)
- # emacs (3)
- # events (1)
- # figwheel-main (3)
- # fulcro (111)
- # hoplon (11)
- # jobs-discuss (97)
- # lein-figwheel (99)
- # off-topic (34)
- # onyx (4)
- # parinfer (9)
- # pedestal (4)
- # precept (2)
- # re-frame (5)
- # reagent (2)
- # reitit (4)
- # ring-swagger (11)
- # shadow-cljs (104)
- # spacemacs (4)
- # tools-deps (19)
- # vim (8)
- # yada (15)
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
(queue
[this interceptors]
"takes a sequence of interceptors and compiles them to queue for the executor")
(execute
[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]
[reitit.interceptor.sieppari]
[ring.adapter.jetty :as jetty]))
(def app
(http/ring-handler
(http/router
["/api"
{:interceptors [{:enter identity}]}
["/hello" {:get (fn [request]
{:status 200
:body "hello!"})}]])
(ring/create-default-handler)
{: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"))
(comment
(start))