Open ccann opened 7 years ago
My API has to conform to the JSON API format http://jsonapi.org/format/
I referenced https://github.com/ngrunwald/ring-middleware-format/commit/6f2930789c1bf43c4001bc4fb19fcab284884a99 and built a custom encoder with application/vnd.api+json as content type but then the charset media type parameter is added. I tried specifying :charset "" in wrap-restful-response options and got an exception re unsupported charset.
application/vnd.api+json
:charset ""
wrap-restful-response
My solution is this janky middleware:
(defn wrap-mime-type "Middleware to replace existing json MIME type with JSON-API MIME type, dropping charset." [handler] (fn [request] (let [response (handler request) headers {"Content-Type" "application/vnd.api+json"}] (if (-> response (get-in [:headers "Content-Type"]) (str/includes? "application/json")) (update-in response [:headers] merge headers) response))))
Is there a way to do this that I missed?
Thanks!
My API has to conform to the JSON API format http://jsonapi.org/format/
I referenced https://github.com/ngrunwald/ring-middleware-format/commit/6f2930789c1bf43c4001bc4fb19fcab284884a99 and built a custom encoder with
application/vnd.api+json
as content type but then the charset media type parameter is added. I tried specifying:charset ""
inwrap-restful-response
options and got an exception re unsupported charset.My solution is this janky middleware:
Is there a way to do this that I missed?
Thanks!