{"id":23070163,"url":"https://github.com/strojure/ring-control","last_synced_at":"2026-03-15T13:55:17.689Z","repository":{"id":65126049,"uuid":"582358169","full_name":"strojure/ring-control","owner":"strojure","description":"More controllable composition of Ring middlewares.","archived":false,"fork":false,"pushed_at":"2023-03-09T13:04:26.000Z","size":98,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"default","last_synced_at":"2025-07-08T07:31:45.501Z","etag":null,"topics":["clojure","ring-handler","ring-middleware"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strojure.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-26T15:13:54.000Z","updated_at":"2023-11-04T13:16:39.000Z","dependencies_parsed_at":"2024-12-16T06:20:14.261Z","dependency_job_id":"369a4d54-bcaf-4291-874f-83a199c9ea1b","html_url":"https://github.com/strojure/ring-control","commit_stats":{"total_commits":60,"total_committers":2,"mean_commits":30.0,"dds":0.09999999999999998,"last_synced_commit":"d94e20bf18dfbb951d1589fa83cc2aaf3d80e63c"},"previous_names":["strojure/ring-stack"],"tags_count":0,"template":false,"template_full_name":"strojure/library-template","purl":"pkg:github/strojure/ring-control","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fring-control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fring-control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fring-control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fring-control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strojure","download_url":"https://codeload.github.com/strojure/ring-control/tar.gz/refs/heads/default","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strojure%2Fring-control/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265424485,"owners_count":23762881,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","ring-handler","ring-middleware"],"created_at":"2024-12-16T06:19:52.943Z","updated_at":"2025-12-12T01:24:59.511Z","avatar_url":"https://github.com/strojure.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ring-control\r\n\r\nMore controllable composition of Ring middlewares.\r\n\r\n[![Clojars Project](https://img.shields.io/clojars/v/com.github.strojure/ring-control.svg)](https://clojars.org/com.github.strojure/ring-control)\r\n\r\n[![cljdoc badge](https://cljdoc.org/badge/com.github.strojure/ring-control)](https://cljdoc.org/d/com.github.strojure/ring-control)\r\n[![tests](https://github.com/strojure/ring-control/actions/workflows/tests.yml/badge.svg)](https://github.com/strojure/ring-control/actions/workflows/tests.yml)\r\n\r\n## Motivation\r\n\r\nThis library is attempt to resolve following difficulties with usage of Ring\r\nmiddlewares:\r\n\r\n- Unclear middleware responsibility, if they handle request, response or both.\r\n- No hints for middleware dependencies, when one middleware works only after\r\n  another.\r\n- Inverted order when written with `-\u003e` macro what makes hard to reason about\r\n  actual request/response flow between wrappers.\r\n\r\n## Usage\r\n\r\n### Building handlers\r\n\r\nRing handlers are build from handler function and sequence of middleware\r\nconfigurations using [handler/build][handler_build] function.\r\n\r\nDefault type of ring handler is sync handler. To produce async ring handler\r\nuse either `:async` option or `{:async true}` in handler's meta.\r\n\r\nEvery middleware configuration is a map with keys:\r\n\r\n- `{:keys [wrap]}`\r\n\r\n  - `:wrap`  – a function `(fn [handler] new-handler)` to wrap handler.\r\n\r\n- `{:keys [enter leave]}`\r\n\r\n  - `:enter` — a function `(fn [request] new-request)` to transform request.\r\n  - `:leave` – a function `(fn [response request] new-response)` to transform\r\n    response.\r\n\r\nMaps with `:wrap` and `:enter`/`:leave` causes exception.\r\n\r\nOnly middlewares with `:wrap` can short-circuit, `:enter`/`:leave` just modify\r\nrequest/response.\r\n\r\nThe middlewares are applied in the order:\r\n\r\n- Request flows from first to last.\r\n- Response flows from last to first.\r\n- Every middleware receives request from *previous* `:wrap`/`:enter`\r\n  middlewares only.\r\n- Every `:leave`/`:wrap` receives response from *next* middlewares.\r\n\r\nSee also [walkthrough](doc/usage/walkthrough.clj).\r\n\r\n### Ring middlewares\r\n\r\nThe [ring-middleware] namespace contains configuration for middlewares in ring\r\nlibraries.\r\n\r\n- [ring/ring-core](https://clojars.org/ring/ring-core)\r\n- [ring/ring-headers](https://clojars.org/ring/ring-headers)\r\n- [ring/ring-ssl](https://clojars.org/ring/ring-ssl)\r\n- [ring/ring-anti-forgery](https://clojars.org/ring/ring-anti-forgery)\r\n- [ring/ring-devel](https://clojars.org/ring/ring-devel)\r\n\r\nThe libraries should be added in project dependencies explicitly for\r\nconfiguration to be used.\r\n\r\nAn implementation of the [ring-defaults](https://clojars.org/ring/ring-defaults)\r\nusing ring-control configurations:\r\n\r\n- [ring-middleware-defaults](src/strojure/ring_control/config/ring_middleware_defaults.clj).\r\n\r\n---\r\n\r\n[handler_build]:\r\nhttps://cljdoc.org/d/com.github.strojure/ring-control/CURRENT/api/strojure.ring-control.handler#build\r\n[ring-middleware]:\r\nhttps://cljdoc.org/d/com.github.strojure/ring-control/CURRENT/api/strojure.ring-control.config.ring-middleware\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrojure%2Fring-control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrojure%2Fring-control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrojure%2Fring-control/lists"}