Fork me on GitHub
#reitit
<
2019-09-22
>
jimi03:09:57

I just realized reitit can do coercion based on the given spec. The examples I have read usually centers around simple spec coercion, e.g. integer? will try to parse given string value to integer. So how do you actually attach a custom coercer? I'm trying to coerce a base64 string from :path-params into a UUID using spec coercion.

ikitommi07:09:56

if uuid? doesn't work for you, you can attach a custom decode function into spec like the doc @U662GKS3F pointed.

jimi00:09:07

Thank you

aaron5114:09:10

Is the "pretty error messages" feature for developers (i.e. for reitit configuration errors) or for users (i.e. invalid parameters sent in a request, or an exception in the handler)? https://github.com/metosin/reitit/blob/master/doc/basics/error_messages.md

ikitommi14:09:46

@aaron51 pretty errors are for developers, all that ansi-printing is not very fast. You can intercept the paremeter errors (for users) and plug in something there too. Here’s example how to use expound with spec messages: https://cljdoc.org/d/metosin/reitit/0.3.9/doc/ring/pluggable-coercion#pretty-printing-spec-errors