Liking cljdoc? Tell your friends :D

ring-lib

Opinionated implementations for Clojure ring handler.

Clojars Project

cljdoc badge tests

Motivation

Being not satisfied with some decisions/implementations in existing Ring libraries.

API

Middlewares

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 {})))

csp

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.

cookies

The alternative implementation of the cookies middleware.

  • Lazy evaluation of the :cookies key in request.
  • Avoids destructuring of the options map in every request.

params

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.

Benchmarks


Authored by Sergey Trofimov.

license

Can you improve this documentation? These fine people already did:
Sergey Trofimov & serioga
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close