Fork me on GitHub
#reitit
<
2021-08-12
>
Charlie Briggs09:08:50

Hey, is it possible to have middleware apply to default routes using ring? The use case is wanting 404s to return JSON responses, and using the same middleware chain as the router to do this. If I try to return a vector/map from reitit.ring/create-default-handler I receive a HTML response from jetty:

Error 500 java.lang.IllegalArgumentException: No implementation of method: :write-body-to-stream of protocol:
		#&apos;ring.core.protocols/StreamableResponseBody found for class: clojure.lang.PersistentArrayMap

Charlie Briggs10:08:08

For reference I’ve followed this example: https://github.com/metosin/reitit/blob/master/examples/ring-malli-swagger/src/example/server.clj so my middleware is defined in -> :data :middleware under ring/router