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
:cookieskey 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-paramswhich is:query-paramsfor GET requests and:body-paramsfor POST request with “application/x-www-form-urlencoded” content type. - Adds
:path-or-query-paramswhich contains params from URL but not body. - Does not add
:paramsas merge of everything else because it is considered confusing. - Optimized for performance.
Authored by Sergey Trofimov.