From 27eb09abd35394538fea5a9c34303bf343d8ae09 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 23 Dec 2015 18:02:45 +0100 Subject: [PATCH 1/3] Update curl documentation --- docs/Hacking.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Hacking.md b/docs/Hacking.md index 651e2028e..4fe1c4bf0 100644 --- a/docs/Hacking.md +++ b/docs/Hacking.md @@ -57,7 +57,7 @@ This makes use of servant, and exposes the following API So it can be accesed by ``` -curl -v http://localhost:8081/req/base -X POST -H Content-Type:application/json --data-binary '{"ideParams":{},"ideCommand":"version","ideContext":{"ctxEndPos":null,"ctxCabal":null,"ctxStartPos":null,"ctxFile":null}}' +curl -v http://localhost:8081/req/base -X POST -H Content-Type:application/json -d '{"params":{},"cmd":"version"}' ```` This returns From 574a23ac2bc376a13bf3ea7509da16721fff8eef Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 23 Dec 2015 18:30:13 +0100 Subject: [PATCH 2/3] Move to a plugin/command url scheme --- src/Haskell/Ide/Engine/Transport/JsonHttp.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Haskell/Ide/Engine/Transport/JsonHttp.hs b/src/Haskell/Ide/Engine/Transport/JsonHttp.hs index 9e06bc99c..115d39601 100644 --- a/src/Haskell/Ide/Engine/Transport/JsonHttp.hs +++ b/src/Haskell/Ide/Engine/Transport/JsonHttp.hs @@ -35,10 +35,10 @@ instance ToJSON Greet -- API specification type HieApi = - -- curl -v http://localhost:8081/req/base -X POST -H Content-Type:application/json --data-binary '{"ideParams":{},"ideCommand":"version","ideContext":{"ctxEndPos":null,"ctxCabal":null,"ctxStartPos":null,"ctxFile":null}}' "req" :> Capture "plugin" Text + :> Capture "command" CommandName :> QueryParam "rid" Int -- optional request id - :> ReqBody '[JSON] IdeRequest + :> ReqBody '[JSON] ParamMap :> Post '[JSON] (IdeResponse Object) :<|> "eg" :> Get '[JSON] IdeRequest @@ -60,9 +60,9 @@ server cin cout = hieH :<|> egH where - hieH plugin mrid reqVal = do + hieH plugin command mrid reqVal = do let rid = fromMaybe 1 mrid - liftIO $ atomically $ writeTChan cin (CReq plugin rid reqVal cout) + liftIO $ atomically $ writeTChan cin (CReq plugin rid (IdeRequest command reqVal) cout) rsp <- liftIO $ atomically $ readTChan cout return (coutResp rsp) -- return (IdeResponseOk (String $ pack $ show r)) From 8581c5df96d6152b67271f8a063e3ff83214f90e Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 23 Dec 2015 18:35:16 +0100 Subject: [PATCH 3/3] Update servant/curl example --- docs/Hacking.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Hacking.md b/docs/Hacking.md index 4fe1c4bf0..14bacffdb 100644 --- a/docs/Hacking.md +++ b/docs/Hacking.md @@ -57,13 +57,13 @@ This makes use of servant, and exposes the following API So it can be accesed by ``` -curl -v http://localhost:8081/req/base -X POST -H Content-Type:application/json -d '{"params":{},"cmd":"version"}' +curl -v -H "Content-Type: application/json" -X POST -d '{"command":{"text": "version"},"plugin":{"text": "base"}}' http://localhost:8001/req/base/commandDetail ```` This returns ```json -{"ok":"Version 0.1.0.0, Git revision 1db8ae98de2e197f5447c0a97f20ca4e06fdbc98 (dirty) (57 commits) x86_64"} +{"contexts":["none"],"return_type":"Text","plugin_name":"base","name":"version","additional_params":[],"ui_description":"return HIE version","file_extensions":[]} ``` ### Plugins