Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
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
Grégoire Locqueville
haskell-gargantext
Commits
265be151
Commit
265be151
authored
Jun 10, 2024
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate servant-routes
parent
49946361
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
8 deletions
+107
-8
Main.hs
bin/gargantext-routes/Main.hs
+54
-0
cabal.project
cabal.project
+6
-1
gargantext.cabal
gargantext.cabal
+19
-0
PolicyCheck.hs
src/Gargantext/API/Auth/PolicyCheck.hs
+9
-2
Types.hs
src/Gargantext/API/Routes/Types.hs
+16
-2
EKG.hs
src/Gargantext/API/Server/Named/EKG.hs
+3
-3
No files found.
bin/gargantext-routes/Main.hs
0 → 100644
View file @
265be151
{-# LANGUAGE LambdaCase #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module
Main
where
import
Data.Aeson.Encode.Pretty
import
Data.ByteString
qualified
as
B
import
Data.ByteString.Lazy
qualified
as
BL
import
Gargantext.API.Routes.Named
import
Options.Applicative
import
Prelude
import
Servant.API
import
Servant.API.Routes
import
Servant.Auth
qualified
as
Servant
data
CLIRoutes
=
CLIR_list
|
CLIR_export
FilePath
deriving
(
Show
,
Eq
)
data
CLI
=
CLIRoutesSub
CLIRoutes
cli
::
Parser
CLI
cli
=
CLIRoutesSub
<$>
(
(
flag'
CLIR_list
(
long
"list"
<>
help
"List all the available routes"
))
<|>
(
CLIR_export
<$>
strOption
(
long
"export"
<>
metavar
"output.json"
<>
help
"Export the routes to a file."
))
)
main
::
IO
()
main
=
runCLI
=<<
execParser
opts
where
opts
=
info
(
cli
<**>
helper
)
(
fullDesc
<>
progDesc
"Print and exports routes for gargantext"
<>
header
"garg-routes helper"
)
instance
HasRoutes
api
=>
HasRoutes
(
Servant
.
Auth
xs
a
:>
api
)
where
getRoutes
=
getRoutes
@
api
instance
HasRoutes
Raw
where
getRoutes
=
[]
runCLI
::
CLI
->
IO
()
runCLI
=
\
case
CLIRoutesSub
CLIR_list
->
printRoutes
@
(
NamedRoutes
API
)
CLIRoutesSub
(
CLIR_export
filePath
)
->
B
.
writeFile
filePath
.
BL
.
toStrict
$
encodePretty
(
getRoutes
@
(
NamedRoutes
API
))
cabal.project
View file @
265be151
...
@@ -165,7 +165,12 @@ source-repository-package
...
@@ -165,7 +165,12 @@ source-repository-package
type
:
git
type
:
git
location
:
https
://
github
.
com
/
robstewart57
/
rdf4h
.
git
location
:
https
://
github
.
com
/
robstewart57
/
rdf4h
.
git
tag
:
4f
d2edf30c141600ffad6d730cc4c1c08a6dbce4
tag
:
4f
d2edf30c141600ffad6d730cc4c1c08a6dbce4
source
-
repository
-
package
type
:
git
location
:
https
://
github
.
com
/
fpringle
/
servant
-
routes
.
git
tag
:
7694f62
af6bc1596d754b42af16da131ac403b3a
allow
-
older
:
*
allow
-
older
:
*
allow
-
newer
:
*
allow
-
newer
:
*
...
...
gargantext.cabal
View file @
265be151
...
@@ -640,6 +640,7 @@ library
...
@@ -640,6 +640,7 @@ library
, servant-flatten ^>= 0.2
, servant-flatten ^>= 0.2
, servant-job >= 0.2.0.0
, servant-job >= 0.2.0.0
, servant-multipart ^>= 0.12.1
, servant-multipart ^>= 0.12.1
, servant-routes < 0.2
, servant-server >= 0.18.3 && < 0.20
, servant-server >= 0.18.3 && < 0.20
, servant-swagger >= 1.2
, servant-swagger >= 1.2
, servant-swagger-ui ^>= 0.3.5.3.5.0
, servant-swagger-ui ^>= 0.3.5.3.5.0
...
@@ -1144,3 +1145,21 @@ executable garg-golden-file-diff
...
@@ -1144,3 +1145,21 @@ executable garg-golden-file-diff
, text
, text
, tree-diff
, tree-diff
default-language: Haskell2010
default-language: Haskell2010
executable garg-routes
import:
defaults
, optimized
main-is: Main.hs
hs-source-dirs:
bin/gargantext-routes
build-depends:
base
, gargantext
, optparse-applicative
, servant-routes
, servant
, servant-auth
, aeson-pretty
, bytestring
default-language: GHC2021
src/Gargantext/API/Auth/PolicyCheck.hs
View file @
265be151
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeApplications #-}
module
Gargantext.API.Auth.PolicyCheck
(
module
Gargantext.API.Auth.PolicyCheck
(
AccessCheck
(
..
)
AccessCheck
(
..
)
...
@@ -34,12 +35,13 @@ import Gargantext.Database.Query.Tree.Root
...
@@ -34,12 +35,13 @@ import Gargantext.Database.Query.Tree.Root
import
Gargantext.Prelude.Config
(
GargConfig
(
..
))
import
Gargantext.Prelude.Config
(
GargConfig
(
..
))
import
Prelude
import
Prelude
import
Servant
import
Servant
import
Servant.API.Routes
import
Servant.Auth.Server.Internal.AddSetCookie
import
Servant.Auth.Server.Internal.AddSetCookie
import
Servant.Client.Core
import
Servant.Ekg
import
Servant.Ekg
import
Servant.Server.Internal.Delayed
import
Servant.Server.Internal.Delayed
import
Servant.Server.Internal.DelayedIO
import
Servant.Server.Internal.DelayedIO
import
qualified
Servant.Swagger
as
Swagger
import
Servant.Swagger
qualified
as
Swagger
import
Servant.Client.Core
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Types
-- Types
...
@@ -203,6 +205,11 @@ instance HasClient m sub => HasClient m (PolicyChecked sub) where
...
@@ -203,6 +205,11 @@ instance HasClient m sub => HasClient m (PolicyChecked sub) where
hoistClientMonad
pm
_
nt
cl
=
hoistClientMonad
pm
(
Proxy
::
Proxy
sub
)
nt
.
cl
hoistClientMonad
pm
_
nt
cl
=
hoistClientMonad
pm
(
Proxy
::
Proxy
sub
)
nt
.
cl
instance
(
HasRoutes
subApi
)
=>
HasRoutes
(
PolicyChecked
subApi
)
where
getRoutes
=
let
apiRoutes
=
getRoutes
@
subApi
in
apiRoutes
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Utility functions
-- Utility functions
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
...
...
src/Gargantext/API/Routes/Types.hs
View file @
265be151
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module
Gargantext.API.Routes.Types
where
module
Gargantext.API.Routes.Types
where
import
Control.Lens
import
Data.ByteString
(
ByteString
)
import
Data.List
qualified
as
L
import
Data.List
qualified
as
L
import
Data.Proxy
import
Data.Proxy
import
Data.Set
qualified
as
Set
import
Gargantext.API.Errors
import
Gargantext.API.Errors
import
Network.Wai
import
Network.Wai
hiding
(
responseHeaders
)
import
Prelude
import
Prelude
import
Servant.Client
import
Servant.API.Routes
import
Servant.Client
hiding
(
responseHeaders
)
import
Servant.Ekg
import
Servant.Ekg
import
Servant.Server
import
Servant.Server
import
Servant.Server.Internal.Delayed
import
Servant.Server.Internal.Delayed
import
Servant.Server.Internal.DelayedIO
import
Servant.Server.Internal.DelayedIO
import
Servant.API.Routes.Route
import
Servant.API.Routes.Internal.Response
(
unResponses
)
data
WithCustomErrorScheme
a
data
WithCustomErrorScheme
a
...
@@ -37,3 +44,10 @@ instance HasClient m sub => HasClient m (WithCustomErrorScheme sub) where
...
@@ -37,3 +44,10 @@ instance HasClient m sub => HasClient m (WithCustomErrorScheme sub) where
clientWithRoute
m
_
req
_mgr
=
clientWithRoute
m
(
Proxy
::
Proxy
sub
)
req
clientWithRoute
m
_
req
_mgr
=
clientWithRoute
m
(
Proxy
::
Proxy
sub
)
req
hoistClientMonad
pm
_
nt
cl
=
hoistClientMonad
pm
(
Proxy
::
Proxy
sub
)
nt
.
cl
hoistClientMonad
pm
_
nt
cl
=
hoistClientMonad
pm
(
Proxy
::
Proxy
sub
)
nt
.
cl
instance
(
HasRoutes
subApi
)
=>
HasRoutes
(
WithCustomErrorScheme
subApi
)
where
getRoutes
=
let
apiRoutes
=
getRoutes
@
subApi
errHeader
=
mkHeaderRep
@
"X-Garg-Error-Scheme"
@
ByteString
addHeader
rt
=
rt
&
routeResponse
.
unResponses
.
traversed
.
responseHeaders
%~
Set
.
insert
errHeader
in
addHeader
<$>
apiRoutes
src/Gargantext/API/Server/Named/EKG.hs
View file @
265be151
...
@@ -9,15 +9,15 @@ import Data.HashMap.Strict as HM
...
@@ -9,15 +9,15 @@ import Data.HashMap.Strict as HM
import
Data.Text
as
T
import
Data.Text
as
T
import
Data.Text.IO
as
T
import
Data.Text.IO
as
T
import
Data.Time.Clock.POSIX
(
getPOSIXTime
)
import
Data.Time.Clock.POSIX
(
getPOSIXTime
)
import
Gargantext.API.Routes.Named.EKG
import
Network.Wai
import
Network.Wai
import
Protolude
import
Protolude
import
Servant
import
Servant
import
Servant.Auth
import
Servant.Auth
import
Servant.Ekg
import
Servant.Ekg
import
System.Metrics
import
qualified
System.Metrics.Json
as
J
import
Gargantext.API.Routes.Named.EKG
import
Servant.Server.Generic
import
Servant.Server.Generic
import
System.Metrics
import
System.Metrics.Json
qualified
as
J
ekgServer
::
FilePath
->
Store
->
EkgAPI
AsServer
ekgServer
::
FilePath
->
Store
->
EkgAPI
AsServer
...
...
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