Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Przemyslaw Kaminski
haskell-gargantext
Commits
9920b17c
Commit
9920b17c
authored
Jun 24, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LOGS] adding log to dev app.
parent
856e569f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
7 deletions
+40
-7
API.hs
src/Gargantext/API.hs
+36
-3
Node.hs
src/Gargantext/API/Node.hs
+4
-4
No files found.
src/Gargantext/API.hs
View file @
9920b17c
...
...
@@ -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
<-
make
Dev
App
env
run
port
app
startGargantextMock
::
PortNumber
->
IO
()
startGargantextMock
port
=
do
portRouteInfo
port
application
<-
makeMockApp
.
MockEnv
$
FireWall
False
run
port
application
src/Gargantext/API/Node.hs
View file @
9920b17c
...
...
@@ -84,7 +84,7 @@ type FacetDocAPI = "table"
:>
QueryParam
"from"
UTCTime
:>
QueryParam
"to"
UTCTime
:>
Get
'[
J
SON
]
[
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
(
"
getN
ode"
::
Text
)
>>
getNode
conn
id
)
nodeAPI
conn
id
=
liftIO
(
putStrLn
(
"
/n
ode"
::
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
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment