Fork me on GitHub
#reitit
<
2020-04-28
>
rlander04:04:59

Quick question: how do I define a custom response coercion? I have a Java class that I want to coerce to BigDecimal just before serialization.

rlander04:04:22

I'm using Schema, btw.

rlander04:04:19

I know how to extend the request coercion using json-coercion-matcher but I have no idea how to add a custom coercion matcher to the response .

rlander04:04:04

Any help would be much appreciated

rlander04:04:43

After some digging, it seems overriding :matchers / :response / :default should do the trick: https://github.com/metosin/reitit/blob/master/modules/reitit-schema/src/reitit/coercion/schema.cljc#L42

rlander04:04:24

Yes, that was it. Just override the default matcher and add your own.

rlander04:04:58

@https://app.slack.com/team/U055NJ5CC I could submit a PR with instructions for this particular case if you get this question a lot (the docs only provide instructions for request coercion).

ikitommi05:04:52

@rlander would be great, looking forward to it!

👍 4
plexus12:04:09

@ikitommi asking here since there's no #pohjavirta (yet). How do you normally deal with having those .java files in the project? I'm using a local checkout now and javac'd them manually

ikitommi15:04:05

@plexus just that too. Deps is so far from the lein experience still. I recall someone made a plugin for this?

plexus15:04:09

thanks! I just did this

for x in **/*.java; do javac -cp `clojure -Spath` $x ; done

orestis18:04:31

A colleague maintains https://github.com/EwenG/badigeon , might be useful.

4
bartuka17:04:46

@ikitommi I started to use #tilakone this week and it really helped to deal with several integration branches I had in a project. are you guys serializing the whole state machine ? if so, what are you using?