Fork me on GitHub
Marco Pas13:02:41

I am trying to create my first ring/compojure application and seem to hit a wall. I am returning a simple JSON response and the app seems to always return with the incorrect content type.

(ns clojure-rest-server.handler
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [ring.util.response :refer [response]]
            [ring.handler.dump :refer [handle-dump]]
            [ring.middleware.json :refer [wrap-json-response wrap-json-body]]
            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]))

(defroutes app-routes
  (POST "/" {body :body} (response {:msg "hello-world"}))
  (route/not-found "Not Found"))

(def app
  (-> (wrap-defaults app-routes api-defaults)
When i do a curl or use postman i allays get a
$ curl -i --header "Content-Type: application/json" \
  --request POST \

HTTP/1.1 200 OK
Date: Fri, 19 Feb 2021 13:30:50 GMT
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Server: Jetty(9.2.21.v20170120)

Any hint what i am doing wrong?


Oh I see you are here already


I hope my posting in #beginners helps


@marco.pasopas here's what I've done. it's quite simple. I am no means a user of compojure, but I hope it helps:

Marco Pas14:02:00

@dharrigan Many thanks!! It seems to work now indeed with your help.

Marco Pas14:02:10

Found an old issue that more or less dscribes this

Marco Pas14:02:33

That whole middleware stuff is a bit confusing. Every demo on the internet more or less make the same mistake. The content type is not taken into account

Marco Pas14:02:56

I should read the manual 🙂


I don't use compojure myself, I prefer #reitit (which uses ring underneath, as the's sorta the defacto standard)

Marco Pas15:02:17

I am hit by the middleware from ring and not so much by compojure, retit will be my next thiing on the todo list 🙂