-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into muuntaja-based-content-encoding-decoding
- Loading branch information
Showing
11 changed files
with
626 additions
and
532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{:paths ["src"] | ||
:deps {gorillalabs/muuntaja {:mvn/version "0.8.0"}} | ||
:aliases {:test {:extra-paths ["test"] | ||
:extra-deps {ring/ring-core {:mvn/version "1.9.5"} | ||
javax.servlet/servlet-api {:mvn/version "2.5"} | ||
funcool/promesa {:mvn/version "8.0.446"} | ||
cheshire/cheshire {:mvn/version "5.10.2"} | ||
com.cognitect/transit-clj {:mvn/version "0.8.319"} | ||
http-kit/http-kit {:mvn/version "2.6.0"} | ||
io.github.cognitect-labs/test-runner | ||
{:git/tag "v0.5.0" :git/sha "48c3c67"}} | ||
:extra-deps {ring/ring-core {:mvn/version "1.9.5"} | ||
javax.servlet/servlet-api {:mvn/version "2.5"} | ||
funcool/promesa {:mvn/version "8.0.446"} | ||
cheshire/cheshire {:mvn/version "5.10.2"} | ||
com.cognitect/transit-clj {:mvn/version "0.8.319"} | ||
http-kit/http-kit {:mvn/version "2.6.0"} | ||
io.github.cognitect-labs/test-runner {:git/tag "v0.5.0" :git/sha "48c3c67"}} | ||
:exec-fn cognitect.test-runner.api/test}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(ns hato.format.text | ||
(:refer-clojure :exclude [format]) | ||
(:require [clojure.edn :as edn] | ||
[muuntaja.format.core :as core]) | ||
(:import (java.io InputStreamReader PushbackReader InputStream OutputStream))) | ||
|
||
(defn decoder [options] | ||
(reify | ||
core/Decode | ||
(decode [_ data charset] | ||
(slurp (InputStreamReader. ^InputStream data ^String charset))))) | ||
|
||
(defn encoder [_] | ||
(reify | ||
core/EncodeToBytes | ||
(encode-to-bytes [_ data charset] | ||
(.getBytes | ||
(str data) | ||
^String charset)) | ||
core/EncodeToOutputStream | ||
(encode-to-output-stream [_ data charset] | ||
(fn [^OutputStream output-stream] | ||
(.write output-stream (.getBytes | ||
(str data) | ||
^String charset)))))) | ||
|
||
(def generic | ||
(core/map->Format | ||
{:name "text/*" | ||
:matches #"^text/(.+)$" | ||
:decoder [decoder] | ||
:encoder [encoder]})) | ||
|
Oops, something went wrong.