This library provides middleware/interceptorware to replace a response containing emoji names with bundled emoji images.
Add to your project.clj:
[emoji "0.1.0"]
The below usages are taken from the full pedestal service and compojure app examples in examples.
To use as an interceptor for a pedestal service:
(require '[io.pedestal.service.interceptor :refer [defon-response]])
(require '[emoji.core :refer [emoji-response]])
(defon-response emoji-interceptor
[response]
(emoji-response response))
;; add emoji-interceptor to a route
["/" {:get some-endpoint ^:interceptors [emoji-interceptor]]
With emoji in place, a response body such as This page is on :fire:
becomes This page is on <img height='20' src='/images/emoji/fire.png' style='vertical-align:middle' width='20' />
.
To use as middleware for a ring app:
(require '[emoji.core :refer [emoji-response]])
(require '[ring.middleware.resource :refer [wrap-resource]])
;; Assuming a compojure routes table called app-routes
;; resource middleware is needed to serve up bundled emojis
(-> app-routes
wrap-emoji
(wrap-resource "/public"))
Options emoji-response
and wrap-emoji
can take:
To copy the bundled emojis: lein trampoline run -m emoji.core [DIRECTORY]
Please report them on github.
For this library's license see LICENSE.TXT. For license of emoji images see gemoji's license.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close