StudistCorporation / ring-accept-language

Home Page:https://biz.teachme.jp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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}

About

https://biz.teachme.jp/

License:MIT License


Languages

Language:Clojure 100.0%