This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-05
Channels
- # announcements (16)
- # babashka (10)
- # beginners (80)
- # calva (18)
- # cider (10)
- # clojure (96)
- # clojure-austin (1)
- # clojure-europe (52)
- # clojure-france (6)
- # clojure-germany (2)
- # clojure-italy (4)
- # clojure-nl (4)
- # clojure-seattle (3)
- # clojure-spec (4)
- # clojure-uk (25)
- # clojurescript (97)
- # community-development (2)
- # cursive (7)
- # datomic (13)
- # figwheel-main (5)
- # fulcro (13)
- # inf-clojure (1)
- # jobs (3)
- # off-topic (33)
- # pathom (10)
- # polylith (8)
- # re-frame (7)
- # reitit (8)
- # releases (1)
- # reveal (2)
- # ring (4)
- # ring-swagger (1)
- # sci (6)
- # shadow-cljs (102)
- # slack-help (1)
- # spacemacs (28)
- # tools-deps (9)
- # vim (1)
- # xtdb (3)
Moro again: is there a way to add custom matchers for Reitit Schema coercion like there is for ring swagger: https://github.com/metosin/ring-swagger#custom-coercions ? I found the current coercions in https://github.com/metosin/schema-tools/blob/master/src/schema_tools/coerce.cljc, but could not figure out a clean way to add more. More specifically, we’d like to corce date strings to OffsetDateTime instances.
@yka depends on which schema lib you are using. For Plumatic: https://github.com/metosin/reitit/blob/0.3.10/modules/reitit-schema/src/reitit/coercion/schema.cljc#L39
Yeah. We are using Prismatic schema. So is the idea to override the default-coercion-matcher
with an own implementation?
Yeah. IIRC it's a map of type => coercion fn, so you'd probably merge your coercers to the existing
Aha, Malli has maps. Schema-tools has these functions: https://github.com/metosin/schema-tools/blob/master/src/schema_tools/coerce.cljc#L284-L287
so you could merge your own impl by using some-fn with existing matcher and your own
Ok. In my case we’d need the matcher for json requests, so I guess I’d need to build on that json-coercion-matcher
and add my own implementation on top of that with some-fn
? I’ll try that approach. Thanks!
So I'm using Reitit and Ring, and I have an endpoint where I need to close a resource when the response has been fully sent (I'm returning an input-stream that's being read from a database, and I need to close the associated transaction). How can I do this?