Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 5e9f52a

Browse files
committed
Merge pull request #148 from cocreature/servant
Move to a plugin/command url scheme
2 parents b810a31 + 8581c5d commit 5e9f52a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/Hacking.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ This makes use of servant, and exposes the following API
5757
So it can be accesed by
5858

5959
```
60-
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}}'
60+
curl -v -H "Content-Type: application/json" -X POST -d '{"command":{"text": "version"},"plugin":{"text": "base"}}' http://localhost:8001/req/base/commandDetail
6161
````
6262
6363
This returns
6464
6565
```json
66-
{"ok":"Version 0.1.0.0, Git revision 1db8ae98de2e197f5447c0a97f20ca4e06fdbc98 (dirty) (57 commits) x86_64"}
66+
{"contexts":["none"],"return_type":"Text","plugin_name":"base","name":"version","additional_params":[],"ui_description":"return HIE version","file_extensions":[]}
6767
```
6868

6969
### Plugins

src/Haskell/Ide/Engine/Transport/JsonHttp.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ instance ToJSON Greet
3535

3636
-- API specification
3737
type HieApi =
38-
-- 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}}'
3938
"req" :> Capture "plugin" Text
39+
:> Capture "command" CommandName
4040
:> QueryParam "rid" Int -- optional request id
41-
:> ReqBody '[JSON] IdeRequest
41+
:> ReqBody '[JSON] ParamMap
4242
:> Post '[JSON] (IdeResponse Object)
4343

4444
:<|> "eg" :> Get '[JSON] IdeRequest
@@ -60,9 +60,9 @@ server cin cout = hieH
6060
:<|> egH
6161

6262
where
63-
hieH plugin mrid reqVal = do
63+
hieH plugin command mrid reqVal = do
6464
let rid = fromMaybe 1 mrid
65-
liftIO $ atomically $ writeTChan cin (CReq plugin rid reqVal cout)
65+
liftIO $ atomically $ writeTChan cin (CReq plugin rid (IdeRequest command reqVal) cout)
6666
rsp <- liftIO $ atomically $ readTChan cout
6767
return (coutResp rsp)
6868
-- return (IdeResponseOk (String $ pack $ show r))

0 commit comments

Comments
 (0)