Skip to content

StudistCorporation/ring-accept-language

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ring Accept-language

Clojars Project

Overview

Ring-Accept-language provides a middleware that parses the Accept-language request header and injects the value into the request hash.

Usage

[jp.studist/ring-accept-language "0.1.1"]

Add a middleware after adding dependencies.

(defn some-middleware
  [handler]
  (wrap-accept-language handler))

The language preferences will be injected in the request map under the :accept-language key. It's a map with the language code (string) for keys and the preference (float) for value.

(defn handler
  [{:keys [accept-language] :as request}]
  (pprint accept-language))

;; {"ja" 1.0, "en-GB" 0.9, "en-US" 0.8, "en" 0.7}