git.iko.soy/typeable/servant-reflex
on master help sign in
Try to call mimeUnrender'
commitc5b26e2a157312fafdaf0e7eae66c915ce429614 authorGreg Hale <imalsogreg@gmail.com> dateThu 30 Mar 2017, 16:14 (10 years ago) parent18fbb6d
1 file changed+7−8
src/Servant/Common/Req.hs+7−8
src/Servant/Common/Req.hs+7−8
@@ -377,7 +377,7 @@ bytesToPayload = TE.decodeUtf8 . BL.toStrict
377377
378378performRequestsCT
379379 :: (SupportsServantReflex t m,
380− MimeUnrender ct a, Traversable f)
380+ MimeUnrender ct a, Traversable f, Typeable ct)
381381 => Proxy ct
382382 -> Text
383383 -> Dynamic t (f (Req t))
@@ -387,8 +387,8 @@ performRequestsCT
387387performRequestsCT ct reqMeth reqs reqHost trigger = do
388388 resps <- performRequests reqMeth reqs reqHost trigger
389389 let decodeResp x = first T.pack .
390− mimeUnrender ct .
391− BL.fromStrict .
390+ mimeUnrender' ct .
391+ -- BL.fromStrict .
392392 TE.encodeUtf8 =<< note "No body text"
393393 (_xhrResponse_responseText x)
394394 return $ fmap
@@ -398,9 +398,9 @@ performRequestsCT ct reqMeth reqs reqHost trigger = do
398398 )
399399 resps
400400
401−mimeUnrender' :: (MimeUnrender ct a, Typeable ct, FromJSON a) => Proxy ct -> BS.ByteString -> Either String a
401+mimeUnrender' :: (MimeUnrender ct a, Typeable ct) => Proxy ct -> BS.ByteString -> Either String a
402402mimeUnrender' p bs
403− | cantRawJson = mimeUnrender p (BL.fromStrict bs)
403+ -- | cantRawJson = mimeUnrender p (BL.fromStrict bs)
404404 | otherwise = note "Raw JSON decode failure" $ rawDecode bs
405405 where
406406 cantRawJson = typeOf (Proxy :: Proxy JSON) /= typeOf p
@@ -439,7 +439,7 @@ aesonFromJSVal r = case jsonTypeOf r of
439439 JSONFloat -> liftM (A.Number . (fromFloatDigits :: Double -> Scientific))
440440 <$> fromJSVal r
441441 JSONBool -> liftM A.Bool <$> fromJSVal r
442− JSONString -> liftM A.String <$> fromJSVal r
442+ JSONString -> liftM (A.String . ("TEST" <>)) <$> fromJSVal r
443443 -- JSONArray -> liftM (A.Array . V.fromList) <$> (fromJSVal r :: _)
444444 JSONArray -> liftM (A.Array . V.fromList) <$>
445445 runMaybeT (traverse (MaybeT . aesonFromJSVal) =<<
@@ -449,9 +449,8 @@ aesonFromJSVal r = case jsonTypeOf r of
449449 runMaybeT $ do
450450 propVals <- forM props $ \p -> do
451451 v <- MaybeT (aesonFromJSVal =<< OI.getProp p (OI.Object r))
452− -- return (JSS.textFromJSString p, v)
453452 return (T.textFromJSString p, v)
454− return (A.Object (H.fromList propVals))
453+ return (A.Object (H.fromList propVals <> H.fromList [("extratest", A.Null)]))
455454{-# INLINE aesonFromJSVal #-}
456455
457456#else