Commit 0627535a authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[List] filename for content-disposition

parent c0fde235
...@@ -23,7 +23,7 @@ Portability : POSIX ...@@ -23,7 +23,7 @@ Portability : POSIX
module Gargantext.API.Ngrams.List module Gargantext.API.Ngrams.List
where where
import Data.Text (Text) import Data.Text (Text, concat, pack)
import Data.Aeson import Data.Aeson
import Data.List (zip) import Data.List (zip)
import Data.Map (Map, toList, fromList) import Data.Map (Map, toList, fromList)
...@@ -45,12 +45,11 @@ instance Accept HTML where ...@@ -45,12 +45,11 @@ instance Accept HTML where
instance ToJSON a => MimeRender HTML a where instance ToJSON a => MimeRender HTML a where
mimeRender _ = encode mimeRender _ = encode
type API = Get '[JSON] NgramsList type API = ReqBody '[JSON] NgramsList :> Put '[JSON] Bool
:<|> ReqBody '[JSON] NgramsList :> Put '[JSON] Bool
:<|> Get '[HTML] (Headers '[Header "Content-Disposition" Text] NgramsList) :<|> Get '[HTML] (Headers '[Header "Content-Disposition" Text] NgramsList)
api :: ListId -> GargServer API api :: ListId -> GargServer API
api l = get l :<|> put l :<|> getHtml l api l = put l :<|> getHtml l
get :: RepoCmdM env err m get :: RepoCmdM env err m
=> ListId -> m NgramsList => ListId -> m NgramsList
...@@ -62,7 +61,8 @@ getHtml :: RepoCmdM env err m ...@@ -62,7 +61,8 @@ getHtml :: RepoCmdM env err m
=> ListId -> m (Headers '[Header "Content-Disposition" Text] NgramsList) => ListId -> m (Headers '[Header "Content-Disposition" Text] NgramsList)
getHtml lId = do getHtml lId = do
lst <- get lId lst <- get lId
return $ addHeader "attachment" lst let (NodeId id) = lId
return $ addHeader (concat ["attachment; filename=list-", pack $ show id, ".json"]) lst
-- TODO : purge list -- TODO : purge list
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment