Fork me on GitHub
#reitit
<
2021-02-05
>
Ykä12:02:38

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.

Ykä12:02:45

Yeah. We are using Prismatic schema. So is the idea to override the default-coercion-matcher with an own implementation?

juhoteperi12:02:49

Yeah. IIRC it's a map of type => coercion fn, so you'd probably merge your coercers to the existing

juhoteperi12:02:23

so you could merge your own impl by using some-fn with existing matcher and your own

Ykä13:02:58

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!

wombawomba23:02:16

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?