implement post fetch (with placeholder content)
This commit is contained in:
parent
970c94ff0d
commit
63bc06a88e
|
@ -108,7 +108,10 @@ postServiceApplication serv = serve exposedPostServiceAPI $ postServer serv
|
|||
exposedPostServiceAPI :: Proxy PostServiceAPI
|
||||
exposedPostServiceAPI = Proxy
|
||||
|
||||
-- ========= constants ===========
|
||||
|
||||
placeholderPost :: Txt.Text
|
||||
placeholderPost = Txt.take 5120 . Txt.repeat $ 'O' -- size 5KiB
|
||||
|
||||
-- ========= HTTP API and handlers =============
|
||||
|
||||
|
@ -175,11 +178,13 @@ subscriptionDelivery serv subList = do
|
|||
enqueueSubscriptions subscriberSTM (normaliseTag tag) sub postList
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
postFetch :: PostService d -> Txt.Text -> Handler Txt.Text
|
||||
postFetch serv postID = pure $ "Here be a post with dragon ID " <> postID
|
||||
postFetch serv postID = do
|
||||
postSet <- liftIO . readTVarIO . ownPosts $ serv
|
||||
if HSet.member postID postSet
|
||||
-- decision: always return the same placeholder post
|
||||
then pure placeholderPost
|
||||
else throwError $ err404 { errBody = "No post found with this ID" }
|
||||
|
||||
postMultiFetch :: PostService d -> Txt.Text -> Handler Txt.Text
|
||||
postMultiFetch serv postIDs = pure $ "Here be multiple post dragons: "
|
||||
|
|
Loading…
Reference in a new issue