Skip to content

ring-clojure/ring-content-encoding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ring-Content-Encoding Build Status

Ring middleware for adding modern response compression to your web application. It supports Brotli, Deflate, GZip and ZStandard content encoding, and has sensible defaults for when to apply compression and when not avoid it (such as for image formats).

Note

Many reverse proxies and CDNs will automatically handle content encoding for you. However, you may want more control over how content encoding is handled, or you may not be using a reverse proxy at all.

Installation

Add the following dependency to your deps.edn file:

org.ring-clojure/ring-content-encoding {:mvn/version "0.1.0-SNAPSHOT"}

Or to your Leiningen project file:

[org.ring-clojure/ring-content-encoding "0.1.0-SNAPSHOT"]

Usage

Use the wrap-content-encoding function to add support for various types of content encoding (i.e. compression).

(require '[ring.middleware.content-encoding :refer [wrap-content-encoding]])

(defn handler [_request]
  {:status  200
   :headers {"Content-Type"   "text/plain; charset=utf-8"
             "Content-Length" "55"}
   :body    "This text will be compressed if the client supports it."})

(def app
  (wrap-content-encoding handler))

License

Copyright © 2026 James Reeves

Released under the MIT license.

About

Ring middleware for response content encoding (compression)

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors