change Mime(Un)Render PlainText String
instances to encode/decode UTF-8 data as specified by Accept PlainText
instance
This commit is contained in:
parent
b3214eac38
commit
0cf045b8fd
1 changed files with 4 additions and 3 deletions
|
@ -82,10 +82,11 @@ import Data.Aeson.Types
|
||||||
(parseEither)
|
(parseEither)
|
||||||
import Data.Attoparsec.ByteString.Char8
|
import Data.Attoparsec.ByteString.Char8
|
||||||
(endOfInput, parseOnly, skipSpace, (<?>))
|
(endOfInput, parseOnly, skipSpace, (<?>))
|
||||||
|
import Data.Bifunctor
|
||||||
|
(bimap)
|
||||||
import qualified Data.ByteString as BS
|
import qualified Data.ByteString as BS
|
||||||
import Data.ByteString.Lazy
|
import Data.ByteString.Lazy
|
||||||
(ByteString, fromStrict, toStrict)
|
(ByteString, fromStrict, toStrict)
|
||||||
import qualified Data.ByteString.Lazy.Char8 as BC
|
|
||||||
import qualified Data.List.NonEmpty as NE
|
import qualified Data.List.NonEmpty as NE
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
(isJust)
|
(isJust)
|
||||||
|
@ -350,7 +351,7 @@ instance MimeRender PlainText TextS.Text where
|
||||||
|
|
||||||
-- | @BC.pack@
|
-- | @BC.pack@
|
||||||
instance MimeRender PlainText String where
|
instance MimeRender PlainText String where
|
||||||
mimeRender _ = BC.pack
|
mimeRender _ = TextL.encodeUtf8 . TextL.pack
|
||||||
|
|
||||||
-- | @id@
|
-- | @id@
|
||||||
instance MimeRender OctetStream ByteString where
|
instance MimeRender OctetStream ByteString where
|
||||||
|
@ -409,7 +410,7 @@ instance MimeUnrender PlainText TextS.Text where
|
||||||
|
|
||||||
-- | @Right . BC.unpack@
|
-- | @Right . BC.unpack@
|
||||||
instance MimeUnrender PlainText String where
|
instance MimeUnrender PlainText String where
|
||||||
mimeUnrender _ = Right . BC.unpack
|
mimeUnrender _ = bimap show TextL.unpack . TextL.decodeUtf8'
|
||||||
|
|
||||||
-- | @Right . id@
|
-- | @Right . id@
|
||||||
instance MimeUnrender OctetStream ByteString where
|
instance MimeUnrender OctetStream ByteString where
|
||||||
|
|
Loading…
Reference in a new issue