Just released ring-nexus-middleware 🎉
Middleware to support FCIS (Functional Core, Imperative Shell) style programming in ring handlers through
github.com/cjohansen/nexus - a zero-dependency data-driven action dispatch system.
Why?
Classic ring handlers are hard to test and, 99% of the time, are impure functions. The classic ring handler goes like this:
1. Add dependencies (DB connection, client with internal secret, etc) to the request map (or to scope with a hoc)
2. Do impure stuff in the request handler body
3. Return a ring map based on the results
What ring-nexus-middleware does:
• Enables Ring handlers to return nexus actions instead of response maps
• Provides built-in HTTP response actions (:http-response/ok, :http-response/bad-request, etc.)
• Adds a pure snapshot of your system to each request
• Works with any “live system” (atoms, Datomic/SQL connections, etc.)
Using ring-nexus-middleware, you can write pure handlers that are easily testable.
Github:
github.com/ovistoica/ring-ne…
Examples:
github.com/ovistoica/ring-ne…
Hope this is useful for you! 🥳