Commit 5136b6b8 authored by Mael NICOLAS's avatar Mael NICOLAS

Done client need to type correctly

parent ddd72b64
{-# 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
......@@ -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
......
{-# 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 '[JSON] T.Text
isidoreAPI :: Proxy ISIDOREAPI
isidoreAPI = Proxy
search :: Maybe Output -> Maybe T.Text -> Maybe T.Text -> ClientM T.Text
search = client isidoreAPI
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