This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-17
Channels
- # aleph (7)
- # announcements (1)
- # aws (12)
- # beginners (118)
- # calva (15)
- # cider (17)
- # clj-kondo (1)
- # cljdoc (11)
- # cljsrn (1)
- # clojure (108)
- # clojure-dev (32)
- # clojure-europe (3)
- # clojure-italy (4)
- # clojure-kc (1)
- # clojure-nl (4)
- # clojure-portugal (1)
- # clojure-spec (29)
- # clojure-uk (69)
- # clojurescript (91)
- # cursive (14)
- # datomic (8)
- # emacs (13)
- # figwheel-main (12)
- # graphql (4)
- # jackdaw (1)
- # jobs (14)
- # lambdaisland (3)
- # luminus (3)
- # nyc (1)
- # off-topic (14)
- # onyx (23)
- # pedestal (8)
- # re-frame (4)
- # reitit (3)
- # shadow-cljs (6)
- # spacemacs (7)
- # specter (2)
- # tools-deps (3)
- # unrepl (4)
- # vim (7)
- # xtdb (10)
@geraldodev content-type-response
is a standard Ring middleware that accepts a handler request -> response
and returns an updated handler request -> response
. Response in assumed to be a steady here-and-now value, so the middleware can access it and modify at will.
Aleph, however, allows the handler to return not only response
, but also (deferred response)
. Ring middleware out-of-the-box doesn't know what to do with deferreds, that it has to chain callbacks onto them rather than call functions directly. So, this defer
function transforms a regular Ring middleware into deferred-aware middleware.
Answering your exact question, (handler req)
can be invoked directly because req
cannot be a deferred, it's always a concrete value.
@geraldodev The request comes in as a Netty request, while the response is a Deferred, so that's why we're chaining only the response, to be able to access its content.
@alexyakushev wonder if its possible to use Ring's async handler arity to chain the deferred callbacks, instead of changing the middleware handlers.
I never tried Ring async arity, so I'm not sure how complete and usable it is.
@dimovich The request actually comes as a Ring request, it is transformed from Netty request to Ring request inside Aleph.
Or you can say it's a NettyRequest implementation-wise, but for the purposes of using Ring it's a valid up-to-spec Ring request.