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

Move to a plugin/command url scheme #148

Merged
merged 3 commits into from
Dec 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/Hacking.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 --data-binary '{"ideParams":{},"ideCommand":"version","ideContext":{"ctxEndPos":null,"ctxCabal":null,"ctxStartPos":null,"ctxFile":null}}'
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
Expand Down
8 changes: 4 additions & 4 deletions src/Haskell/Ide/Engine/Transport/JsonHttp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down