Commit 9920b17c authored by Alexandre Delanoë's avatar Alexandre Delanoë

[LOGS] adding log to dev app.

parent 856e569f
......@@ -143,6 +143,41 @@ makeMockApp env = do
pure $ logStdoutDev $ checkOriginAndHost $ corsMiddleware $ serverApp
--
makeDevApp :: Env -> IO Application
makeDevApp env = do
serverApp <- makeApp env
-- logWare <- mkRequestLogger def { destination = RequestLogger.Logger $ env^.logger }
--logWare <- mkRequestLogger def { destination = RequestLogger.Logger "/tmp/logs.txt" }
-- let checkOriginAndHost app req resp = do
-- blocking <- fireWall req (env ^. menv_firewall)
-- case blocking of
-- True -> app req resp
-- False -> resp ( responseLBS status401 []
-- "Invalid Origin or Host header")
--
let corsMiddleware = cors $ \_ -> Just CorsResourcePolicy
-- { corsOrigins = Just ([env^.settings.allowedOrigin], False)
{ corsOrigins = Nothing -- == /*
, corsMethods = [ methodGet , methodPost , methodPut
, methodDelete, methodOptions, methodHead]
, corsRequestHeaders = ["authorization", "content-type"]
, corsExposedHeaders = Nothing
, corsMaxAge = Just ( 60*60*24 ) -- one day
, corsVaryOrigin = False
, corsRequireOrigin = False
, corsIgnoreFailures = False
}
--let warpS = Warp.setPort (8008 :: Int) -- (env^.settings.appPort)
-- $ Warp.defaultSettings
--pure (warpS, logWare $ checkOriginAndHost $ corsMiddleware $ serverApp)
pure $ logStdoutDev $ corsMiddleware $ serverApp
--
---------------------------------------------------------------------
-- | API Global
......@@ -264,14 +299,12 @@ startGargantext :: PortNumber -> FilePath -> IO ()
startGargantext port file = do
env <- newEnv port file
portRouteInfo port
app <- makeApp env
app <- makeDevApp env
run port app
startGargantextMock :: PortNumber -> IO ()
startGargantextMock port = do
portRouteInfo port
application <- makeMockApp . MockEnv $ FireWall False
run port application
......@@ -84,7 +84,7 @@ type FacetDocAPI = "table"
:> QueryParam "from" UTCTime
:> QueryParam "to" UTCTime
:> Get '[JSON] [FacetChart]
--
-- Depending on the Type of the Node, we could post
-- New documents for a corpus
-- New map list terms
......@@ -96,13 +96,13 @@ type FacetDocAPI = "table"
-- | Node API functions
roots :: Connection -> Server Roots
roots conn = liftIO (putStrLn ( "Log Needed" :: Text) >> getNodesWithParentId conn 0 Nothing)
roots conn = liftIO (putStrLn ( "/user" :: Text) >> getNodesWithParentId conn 0 Nothing)
:<|> pure (panic "not implemented yet")
:<|> pure (panic "not implemented yet")
:<|> pure (panic "not implemented yet")
nodeAPI :: Connection -> NodeId -> Server NodeAPI
nodeAPI conn id = liftIO (putStrLn ("getNode" :: Text) >> getNode conn id )
nodeAPI conn id = liftIO (putStrLn ("/node" :: Text) >> getNode conn id )
:<|> deleteNode' conn id
:<|> getNodesWith' conn id
:<|> getFacet conn id
......@@ -126,7 +126,7 @@ getNodesWith' conn id nodeType offset limit = liftIO (getNodesWith conn id node
getFacet :: Connection -> NodeId -> Maybe Int -> Maybe Int
-> Handler [FacetDoc]
getFacet conn id offset limit = liftIO (getDocFacet conn id (Just Document) offset limit)
getFacet conn id offset limit = liftIO (putStrLn ( "/facet" :: Text)) >> liftIO (getDocFacet conn Corpus id (Just Document) offset limit)
getChart :: Connection -> NodeId -> Maybe UTCTime -> Maybe UTCTime
-> Handler [FacetChart]
......
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