Opinionated implementations for Clojure ring handler.
Being not satisfied with some decisions/implementations in existing Ring libraries.
Some middlewares in this library does not provide wrap-middleware
function.
There are middleware builder functions in strojure.ring-lib.middleware.core
namespace:
(require '[strojure.ring-lib.middleware.core :as mw]
'[strojure.ring-lib.middleware.params :as params])
(-> handler
(mw/wrap-request (params/params-request-fn {})))
The implementation of Content Security Policy (CSP).
- Supports static CSP headers and headers with nonce.
- Renders policy from Clojure map.
- Follows recommendations for nonce generation.
- Configurable usage of report-only CSP header.
- Handles report URI endpoint.
The alternative implementation of the cookies middleware.
- Lazy evaluation of the
:cookies
key in request. - Avoids destructuring of the options map in every request.
The alternative implementation of the params middleware.
- Name dependent detection if param is single value or collection, by default
only names with
[]
suffix has collection value. - Lazy evaluation of request keys.
- Allows to customize param names with collection values.
- Allows to define coercion function for param names, i.e. to keywordize them.
- Adds
:form-params
which is:query-params
for GET requests and:body-params
for POST request with “application/x-www-form-urlencoded” content type. - Adds
:path-or-query-params
which contains params from URL but not body. - Does not add
:params
as merge of everything else because it is considered confusing. - Optimized for performance.
Authored by Sergey Trofimov.