Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
isidore
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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
gargantext
crawlers
isidore
Commits
5136b6b8
Commit
5136b6b8
authored
Jun 13, 2019
by
Mael NICOLAS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Done client need to type correctly
parent
ddd72b64
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
1 deletion
+58
-1
Main.hs
app/Main.hs
+16
-1
package.yaml
package.yaml
+7
-0
Client.hs
src/ISIDORE/Client.hs
+35
-0
No files found.
app/Main.hs
View file @
5136b6b8
{-# LANGUAGE OverloadedStrings #-}
module
Main
where
import
Lib
import
ISIDORE.Client
import
Network.HTTP.Client
(
newManager
)
import
Network.HTTP.Client.TLS
(
tlsManagerSettings
)
import
Servant.Client
main
::
IO
()
main
=
someFunc
main
=
do
manager'
<-
newManager
tlsManagerSettings
res
<-
runClientM
(
search
(
Just
JSON
)
(
Just
"colza"
)
(
Nothing
))
(
mkClientEnv
manager'
$
BaseUrl
Https
"api.isidore.science"
443
"resource"
)
case
res
of
(
Left
err
)
->
print
err
(
Right
val
)
->
print
val
package.yaml
View file @
5136b6b8
...
...
@@ -21,6 +21,13 @@ description: Please see the README on GitHub at <https://github.com/gith
dependencies
:
-
base >= 4.7 && < 5
-
servant
-
servant-client
-
text
-
bytestring
-
http-client
-
http-client-tls
-
http-media
library
:
source-dirs
:
src
...
...
src/ISIDORE/Client.hs
0 → 100644
View file @
5136b6b8
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module
ISIDORE.Client
where
import
Servant.API
import
Servant.Client
import
Data.Proxy
(
Proxy
(
..
))
import
Data.ByteString.Lazy
(
ByteString
)
import
qualified
Data.Text
as
T
data
Output
=
JSON
instance
ToHttpApiData
Output
where
toUrlPiece
JSON
=
"json"
type
ISIDOREAPI
=
Search
-- search?q=colza&output=json&replies=1&author=jm&
type
Search
=
"search"
:>
QueryParam
"output"
Output
:>
QueryParam
"q"
T
.
Text
:>
QueryParam
"author"
T
.
Text
:>
Get
'[
J
SON
]
T
.
Text
isidoreAPI
::
Proxy
ISIDOREAPI
isidoreAPI
=
Proxy
search
::
Maybe
Output
->
Maybe
T
.
Text
->
Maybe
T
.
Text
->
ClientM
T
.
Text
search
=
client
isidoreAPI
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