Skip to content
Dave Liepmann edited this page May 30, 2014 · 2 revisions

You can use the wrap-content-type middleware to add a Content-Type header based on the file extension in the URI:

(use 'ring.middleware.content-type)

(def app
  (wrap-content-type your-handler))

So if a user accessed a stylesheet at:

http://example.com/style/screen.css

Then the content-type middleware would add the following header:

Content-Type: text/css

You can take a look at the default content type mappings in the ring-core/src/ring/util/mime_types.clj.

You can also add custom mime-types by using the :mime-types option:

(use 'ring.middleware.content-type)

(def app
  (wrap-content-type
   your-handler
   {:mime-types {"foo" "text/x-foo"}}))