Get DataClient to build without issues
This commit is contained in:
parent
ad6300fa6b
commit
ff3667516a
|
@ -1 +1 @@
|
|||
Subproject commit 62a23581e786f8564653406845c4b2a07d73deb6
|
||||
Subproject commit b868e4614f3fb56517e65b6965fc011f9190e70d
|
|
@ -3,14 +3,21 @@ module DataClient
|
|||
)
|
||||
where
|
||||
|
||||
import Common.Network.ClientTypes (Model (..))
|
||||
import Data.Time.Clock (UTCTime)
|
||||
import qualified Data.ByteString.Lazy as LBS
|
||||
import qualified Data.ByteString.Lazy.Char8 as LC8
|
||||
|
||||
import Common.Network.CatalogPostType (CatalogPost)
|
||||
import Common.Network.ClientTypes (Model (..), FetchCatalogArgs (..))
|
||||
import Common.Network.HttpClient
|
||||
( post
|
||||
, HttpError
|
||||
, HttpError (..)
|
||||
)
|
||||
import Data.Aeson (eitherDecode, encode, FromJSON)
|
||||
import Common.Server.JSONSettings (JSONSettings)
|
||||
|
||||
fetchLatest :: Model -> UTCTime -> IO IO (Either HttpError [ CatalogPost ])
|
||||
fetchLatest m t iface = do
|
||||
fetchLatest :: JSONSettings -> Model -> UTCTime -> IO (Either HttpError [ CatalogPost ])
|
||||
fetchLatest settings m t = do
|
||||
post settings "/rpc/fetch_catalog" payload False >>= return . eitherDecodeResponse
|
||||
|
||||
where
|
||||
|
@ -18,3 +25,11 @@ fetchLatest m t iface = do
|
|||
{ max_time = t
|
||||
, max_row_read = fetchCount m
|
||||
}
|
||||
|
||||
|
||||
eitherDecodeResponse :: (FromJSON a) => Either HttpError LBS.ByteString -> Either HttpError a
|
||||
eitherDecodeResponse (Left err) = Left err
|
||||
eitherDecodeResponse (Right bs) =
|
||||
case eitherDecode bs of
|
||||
Right val -> Right val
|
||||
Left err -> Left $ StatusCodeError 500 $ LC8.pack $ "Failed to decode JSON: " ++ err ++ " " ++ (show bs)
|
||||
|
|
|
@ -12,7 +12,7 @@ import qualified Network.Wai.Middleware.RequestLogger as Wai
|
|||
import Servant.API
|
||||
import Servant.Server (Server, Handler (..), serve)
|
||||
import qualified Lucid as L
|
||||
import qualified Lucid.Base as L
|
||||
-- import qualified Lucid.Base as L
|
||||
|
||||
|
||||
import qualified Common.FrontEnd.Routes as FE
|
||||
|
|
|
@ -84,6 +84,7 @@ executable chandlr-server
|
|||
Common.Network.SiteType
|
||||
Common.Network.ThreadType
|
||||
Common.Network.Units
|
||||
Common.Network.HttpClient
|
||||
Common.Parsing.EmbedParser
|
||||
Common.Parsing.PostBodyUtils
|
||||
Common.Parsing.PostPartType
|
||||
|
|
Loading…
Reference in New Issue