This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-31
Channels
- # aws (2)
- # beginners (101)
- # cider (8)
- # clara (8)
- # cljs-dev (3)
- # cljsrn (17)
- # clojars (2)
- # clojure (67)
- # clojure-austin (2)
- # clojure-finland (1)
- # clojure-france (5)
- # clojure-italy (3)
- # clojure-nl (3)
- # clojure-russia (2)
- # clojure-serbia (1)
- # clojure-spec (72)
- # clojure-uk (112)
- # clojurescript (92)
- # core-async (74)
- # core-typed (2)
- # cursive (8)
- # datomic (2)
- # duct (5)
- # emacs (35)
- # events (11)
- # fulcro (32)
- # instaparse (9)
- # jobs (1)
- # luminus (1)
- # lumo (3)
- # off-topic (118)
- # om (2)
- # onyx (10)
- # pedestal (5)
- # re-frame (21)
- # reagent (48)
- # reitit (40)
- # ring (12)
- # shadow-cljs (113)
- # spacemacs (21)
- # tools-deps (47)
Hi, I'm using ring-defaults
middleware to get the ring.middleware.params/wrap-params
(I'm also using munntaja.middleware/wrap-format
), and these seem to be adding in nil
values for :body
(and :query-string
respectively). This stops the requests being ring-spec compliant, as these keys are not nilable
- is there a way to get wrap-params
to remove the key instead of adding in a nil
value to keep the request spec-compliant?
I see a failure on the first invocation of my handler function after locating it with reitit routing
Here's my error (via expound):
Call to #'hanabi.web/initialise did not conform to spec:
web.clj:181
-- Spec failed --------------------
Function arguments
({:reitit.core/match ...,
:reitit.core/router ...,
:remote-addr ...,
:params ...,
:headers ...,
:async-channel ...,
:server-port ...,
:content-length ...,
:form-params ...,
:websocket? ...,
:web/session ...,
:query-params ...,
:content-type ...,
:character-encoding ...,
:uri ...,
:server-name ...,
:query-string ...,
:path-params ...,
:body nil,
^^^
:scheme ...,
:request-method ...})
should satisfy
#object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x765709fc "clojure.spec.alpha$regex_spec_impl$reify__2436@765709fc"]
-- Relevant specs -------
:ring.request/body:
:clojure.spec.alpha/unknown
:ring/request:
(clojure.spec.alpha/keys
:req-un
[:ring.request/server-port
:ring.request/server-name
:ring.request/remote-addr
:ring.request/uri
:ring.request/scheme
:ring.request/protocol
:ring.request/headers
:ring.request/request-method]
:opt-un
[:ring.request/query-string :ring.request/body])
:web.ring/request:
(clojure.spec.alpha/merge
:ring/request
(clojure.spec.alpha/keys
:req
[:web/session]
:req-un
[:web.ring.request/edn-params]))
-- Spec failed --------------------
Function arguments
({:reitit.core/match ...,
:reitit.core/router ...,
:remote-addr ...,
:params ...,
:headers ...,
:async-channel ...,
:server-port ...,
:content-length ...,
:form-params ...,
:websocket? ...,
:web/session ...,
:query-params ...,
:content-type ...,
:character-encoding ...,
:uri ...,
:server-name ...,
:query-string nil,
^^^
:path-params ...,
:body ...,
:scheme ...,
:request-method ...})
should satisfy
#object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x765709fc "clojure.spec.alpha$regex_spec_impl$reify__2436@765709fc"]
-- Relevant specs -------
:ring.request/query-string:
:clojure.spec.alpha/unknown
:ring/request:
(clojure.spec.alpha/keys
:req-un
[:ring.request/server-port
:ring.request/server-name
:ring.request/remote-addr
:ring.request/uri
:ring.request/scheme
:ring.request/protocol
:ring.request/headers
:ring.request/request-method]
:opt-un
[:ring.request/query-string :ring.request/body])
:web.ring/request:
(clojure.spec.alpha/merge
:ring/request
(clojure.spec.alpha/keys
:req
[:web/session]
:req-un
[:web.ring.request/edn-params]))
-------------------------
Detected 2 errors
it appears that the request that reaches my handler contains the :body
and :query-string
keys both with nil
values, so the problem is not with middleware, sorry
i've raised an issue with httpkit: https://github.com/http-kit/http-kit/issues/377
I've just tried with jetty, same result. Both send requests with nil
values for :body
and :query-string
The spec: https://github.com/ring-clojure/ring-spec/blob/master/src/ring/core/spec.clj#L115