mirror of
https://github.com/ilyakooo0/servant-reflex.git
synced 2024-09-11 07:15:29 +03:00
Fixup merge
This commit is contained in:
parent
120c5ca7c6
commit
bdbcbfa0f4
@ -24,8 +24,7 @@ library
|
||||
|
||||
hs-source-dirs: src
|
||||
build-depends:
|
||||
base >= 4.8 && < 4.10,
|
||||
aeson >= 0.11 && < 1.3,
|
||||
aeson >= 0.11 && < 1.5,
|
||||
base >= 4.8 && < 5,
|
||||
bytestring >= 0.10 && < 0.11,
|
||||
case-insensitive >= 1.2.0.4 && < 1.3,
|
||||
@ -41,8 +40,8 @@ library
|
||||
reflex >= 0.5 && < 0.7,
|
||||
reflex-dom-core >= 0.4 && < 0.6,
|
||||
safe >= 0.3.9 && < 0.4,
|
||||
servant >= 0.13 && < 0.14,
|
||||
servant-checked-exceptions >= 1.1.0.0 && < 1.2,
|
||||
servant >= 0.13 && < 0.16,
|
||||
servant-checked-exceptions >= 2.0 && < 2.2,
|
||||
servant-auth >= 0.2.1 && < 0.4,
|
||||
string-conversions >= 0.4 && < 0.5,
|
||||
text >= 1.2 && < 1.3,
|
||||
|
@ -36,7 +36,7 @@ import Data.Monoid ((<>))
|
||||
import Data.Proxy (Proxy (..))
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
import qualified Data.Text.Encoding as TE
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import Data.Traversable (forM)
|
||||
import qualified Language.Javascript.JSaddle as JS
|
||||
@ -181,7 +181,7 @@ prependToPathParts p req =
|
||||
req { reqPathParts = p : reqPathParts req }
|
||||
|
||||
addHeader :: (ToHttpApiData a, Reflex t) => Text -> Dynamic t (Either Text a) -> Req t -> Req t
|
||||
addHeader name val req = req { headers = (name, (fmap . fmap) (T.decodeUtf8 . toHeader) val) : headers req }
|
||||
addHeader name val req = req { headers = (name, (fmap . fmap) (TE.decodeUtf8 . toHeader) val) : headers req }
|
||||
|
||||
reqToReflexRequest
|
||||
:: forall t. Reflex t
|
||||
@ -275,8 +275,8 @@ reqToReflexRequest reqMeth reqHost req@(Req _ _ _ (reqBody :: Maybe (Dynamic t (
|
||||
mkAuth _ (Left e) = Left e
|
||||
mkAuth Nothing r = r
|
||||
mkAuth (Just (BasicAuthData u p)) (Right config) = Right $ config
|
||||
{ _xhrRequestConfig_user = Just $ T.decodeUtf8 u
|
||||
, _xhrRequestConfig_password = Just $ T.decodeUtf8 p}
|
||||
{ _xhrRequestConfig_user = Just $ TE.decodeUtf8 u
|
||||
, _xhrRequestConfig_password = Just $ TE.decodeUtf8 p}
|
||||
|
||||
addAuth :: Dynamic t (Either Text (XhrRequestConfig x))
|
||||
-> Dynamic t (Either Text (XhrRequestConfig x))
|
||||
@ -449,7 +449,7 @@ instance FromJSON a => MimeUnrender JSON a where
|
||||
-- Note that the @mimeUnrender p (mimeRender p x) == Right x@ law only
|
||||
-- holds if every element of x is non-null (i.e., not @("", "")@)
|
||||
instance FromForm a => MimeUnrender FormUrlEncoded a where
|
||||
mimeUnrender _ = first T.unpack . urlDecodeAsForm . BB.toLazyByteString . T.encodeUtf8Builder . JS.textFromJSString
|
||||
mimeUnrender _ = first T.unpack . urlDecodeAsForm . Builder.toLazyByteString . TE.encodeUtf8Builder . JS.textFromJSString
|
||||
|
||||
-- | @left show . TextL.decodeUtf8'@
|
||||
instance MimeUnrender PlainText TL.Text where
|
||||
@ -465,11 +465,11 @@ instance MimeUnrender PlainText String where
|
||||
|
||||
-- | @Right . id@
|
||||
instance MimeUnrender OctetStream ByteString where
|
||||
mimeUnrender _ = pure . BB.toLazyByteString . T.encodeUtf8Builder . JS.textFromJSString
|
||||
mimeUnrender _ = pure . Builder.toLazyByteString . TE.encodeUtf8Builder . JS.textFromJSString
|
||||
|
||||
-- | @Right . toStrict@
|
||||
instance MimeUnrender OctetStream BS.ByteString where
|
||||
mimeUnrender _ = pure . T.encodeUtf8 . JS.textFromJSString
|
||||
mimeUnrender _ = pure . TE.encodeUtf8 . JS.textFromJSString
|
||||
|
||||
note :: e -> Maybe a -> Either e a
|
||||
note e Nothing = Left e
|
||||
@ -479,8 +479,8 @@ fmapL :: (e -> e') -> Either e a -> Either e' a
|
||||
fmapL _ (Right a) = Right a
|
||||
fmapL f (Left e) = Left (f e)
|
||||
|
||||
builderToText :: BB.Builder -> T.Text
|
||||
builderToText = T.decodeUtf8 . BL.toStrict . BB.toLazyByteString
|
||||
builderToText :: Builder.Builder -> T.Text
|
||||
builderToText = TE.decodeUtf8 . BL.toStrict . Builder.toLazyByteString
|
||||
|
||||
escape :: T.Text -> T.Text
|
||||
escape = T.pack . N.escapeURIString (not . N.isReserved) . T.unpack . TE.decodeUtf8 . BL.toStrict . Builder.toLazyByteString . toEncodedUrlPiece
|
||||
|
@ -105,7 +105,7 @@ import Reflex.Dom.Core (Dynamic,
|
||||
leftmost,
|
||||
performRequestsAsync)
|
||||
------------------------------------------------------------------------------
|
||||
import Servant.Checked.Exceptions.Internal.Envelope (Envelope)
|
||||
import Servant.Checked.Exceptions.Internal (Envelope)
|
||||
import Servant.Checked.Exceptions.Internal.Servant.API (NoThrow,
|
||||
Throwing,
|
||||
ThrowingNonterminal,
|
||||
|
@ -79,7 +79,7 @@ import Reflex.Dom.Core (Dynamic,
|
||||
attachPromptlyDynWith,
|
||||
constDyn)
|
||||
------------------------------------------------------------------------------
|
||||
import Servant.Checked.Exceptions.Internal.Envelope (Envelope)
|
||||
import Servant.Checked.Exceptions.Internal (Envelope)
|
||||
import Servant.Checked.Exceptions.Internal.Servant.API (NoThrow,
|
||||
Throwing,
|
||||
ThrowingNonterminal,
|
||||
|
Loading…
Reference in New Issue
Block a user