Skip to content

Instantly share code, notes, and snippets.

@sw-samuraj
Created May 1, 2017 06:43
Show Gist options
  • Save sw-samuraj/af6ee199af9b0b12477595f8a54f94a5 to your computer and use it in GitHub Desktop.
Save sw-samuraj/af6ee199af9b0b12477595f8a54f94a5 to your computer and use it in GitHub Desktop.
An example of Ring middlewares wrap-params and wrap-keyword-params (for a blog post).
(ns blog-ring.middleware
(:require [ring.middleware.params :refer [wrap-params]]
[ring.middleware.keyword-params :refer [wrap-keyword-params]]))
((wrap-params identity)
{:query-string "clojure=yes&lisp=maybe"})
;; -> {:query-string "clojure=yes&lisp=maybe",
;; :form-params {},
;; :params {"clojure" "yes", "lisp" "maybe"},
;; :query-params {"clojure" "yes", "lisp" "maybe"}}
((wrap-keyword-params identity)
{:params {"clojure" "yes" "lisp" "maybe"}})
;; -> {:params {:clojure "yes", :lisp "maybe"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment