If my compojure-api API gives a 500 with a path containing spaces e.g
/api/foo/some id with spaces, is that a bug in the library or something I've not done as a developer? (perhaps added some ring middleware?)
@mgrbyte good question, haven't seen that. Could you test that with plain Compojure? 500 sounds odd thou.
Just tracked it down. Have a custom error handler which tries to turn spec errors into an error message with
bad-request. spec validation error couldn't be written to stream, so answered my own question.
tracked down exactly the cause. My error handler uses a small function to encode the response:
For some reason,
(defn respond-with [response-fn request data] (let [fmt (-> request :compojure.api.request/muuntaja :default-format)] (-> data (response-fn) (content-type fmt))))
:default-formatin this case, is
nil, causing the 500 error (cannot write persistentarraymap). It works in most other cases :thinking_face:
(:compojure.api.request/muuntaja request) is nil.
@ikitommi I see from compojure-api's
path-for* function that this might happen - I'm guessing there are cases where the muuntaja instance might not present in the request, and one has define another default?