Commit 1fd46635 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[API] WebSockets (WIP)

parent a3caa26a
......@@ -217,6 +217,7 @@ library:
- servant-static-th
- servant-swagger
- servant-swagger-ui
- servant-websockets
- servant-xml
- simple-reflect
- singletons # (IGraph)
......
......@@ -178,9 +178,6 @@ makeDevMiddleware mode = do
-- | API Global
---------------------------------------------------------------------
---------------------------
-- TODO-SECURITY admin only: withAdmin
-- Question: How do we mark admins?
{-
......@@ -226,4 +223,4 @@ type family GenericTypeName t (r :: *) :: Symbol where
GenericTypeName t (D1 ('MetaData name mod pkg nt) f x) = name
type Desc t n = Description (AppendSymbol (TypeName t) (AppendSymbol " | " n))
-}
\ No newline at end of file
-}
......@@ -26,6 +26,12 @@ module Gargantext.API.Routes
import Control.Concurrent (threadDelay)
import Control.Lens (view)
import Data.Text (Text)
import Data.Aeson (Value)
import Data.Conduit (ConduitT)
import Servant.API.WebSocketConduit (WebSocketConduit, WebSocketSource)
import qualified Data.Conduit.List as CL
import Data.Validity
import Gargantext.API.Admin.Auth.Types (AuthRequest, AuthResponse, AuthenticatedUser(..), PathId(..))
import Gargantext.API.Admin.Auth (withAccess)
......@@ -168,6 +174,10 @@ type GargPrivateAPI' =
:> Capture "x" Int
:> WaitAPI -- Get '[JSON] Int
-}
:<|> "ws" :> Summary "WebSocket Test Route"
:> WebSocketConduit Value Value
-- /mv/<id>/<id>
-- /merge/<id>/<id>
-- /rename/<id>
......@@ -239,7 +249,12 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
-- :<|> New.info uid -- TODO-SECURITY
:<|> List.api
-- :<|> waitAPI
:<|> echo
-- FIXME which Monad type it is ?
-- echo :: ConduitT Value Value ?? ()
echo = CL.map identity
----------------------------------------------------------------------
-- For Tests
......
......@@ -90,7 +90,10 @@ fisWithSize n f is = case n of
fisWith :: Maybe ([Item] -> Bool) -> Frequency -> [[Item]] -> [Fis]
fisWith s f is = case filter (not . null) is of
[] -> []
js -> catMaybes $ map items2fis $ filter' $ runLCMmatrix js f
js -> catMaybes
$ map items2fis
$ filter'
$ runLCMmatrix js f
-- drop unMaybe
where
filter' = case s of
......
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