This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-12
Channels
- # announcements (1)
- # architecture (112)
- # asami (22)
- # babashka (74)
- # beginners (189)
- # chlorine-clover (4)
- # cider (105)
- # clj-kondo (21)
- # clojure (45)
- # clojure-australia (1)
- # clojure-europe (26)
- # clojure-losangeles (4)
- # clojure-nl (3)
- # clojure-spec (5)
- # clojure-uk (8)
- # clojurescript (16)
- # conjure (1)
- # cursive (29)
- # datascript (21)
- # datomic (35)
- # events (1)
- # fulcro (12)
- # graalvm (3)
- # graphql (31)
- # kaocha (13)
- # malli (14)
- # meander (3)
- # mount (3)
- # off-topic (73)
- # pathom (9)
- # pedestal (5)
- # portal (2)
- # re-frame (4)
- # reagent (8)
- # reitit (3)
- # rum (1)
- # shadow-cljs (26)
- # spacemacs (3)
- # sql (6)
I have a pedestal app (a REST API) that must respond quickly before actually doing the (long) work
i.e: receive a POST request, verify the auth token checks out, data sent is good, then return 200 ok
within 3 seconds
But after that I actually do some heavy work with lots of branching, and the same branchings can be reused many times, and the pedestal HTTP mechanism is gone because I already replied to the request.
I initially thought about turning the branchings into reusable macros, but I realized that's the job pedestal does, except I use it for HTTP requests. And the website says it's not just for HTTP!
Great, though how do I get started? what's the entry point to generate a new non-HTTP context, add non-HTTP interceptors, and get it running?
Here's a toy example:
(:require
[io.pedestal.interceptor :as i]
[io.pedestal.interceptor.chain :as chain]
[io.pedestal.interceptor.helpers :as ih])
(def i1 (i/interceptor {:enter (fn [c] (log/info "in i1") c)}))
(def i2 (i/interceptor {:enter (fn [c] (go (log/info "in i2")) c)}))
(def i3 (ih/before (fn [c] (log/info "in i3") c)))
(def my-ints [i1 i2 i3])
(chain/execute {} my-ints)
(chain/execute-only {} :enter my-ints)
that looks great, I'll try it out tonight
thanks!