Skip to content

Commit

Permalink
Add HTTP API document.
Browse files Browse the repository at this point in the history
  • Loading branch information
yangziy committed Sep 17, 2018
1 parent 739b040 commit e6f6ae6
Showing 1 changed file with 105 additions and 0 deletions.
105 changes: 105 additions & 0 deletions HTTPAPI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Features

* Check current status (on/off)

- Toggle the client

- Get server list

- Switch server

- Get current mode

- Switch mode

# Specification

- #### Check current status (on/off) `GET /status`

###### Sample Return

```
{
"enable": true
}
```

- #### Toggle the client `POST /toggle`

###### Sample Return

```
{
"status": 1
// 1 for toggle succeed, 0 for fail
}
```

- #### Get server list `GET /servers`

###### Sample Return

```
[
{
"active": 1,
"id": "93C547E0-49C9-1234-9CAD-EE8D5C4A1A8F",
"remark": "us1",
// remark: as in Server Preferences Panel of the app.
},
{
"active" : 0,
"id" : "71552DCD-B298-495E-904E-82DA4B07AEF8",
"remark" : "hk2"
},
{
"active" : 0,
"id" : "E8879F3D-95AE-4714-BC04-9B271C2BC52D",
"remark" : "jp1"
},...
]
```

- #### Switch server `POST /servers`

###### Argument

| Name | Description | Sample |
| ---- | ----------------------------- | -------------------------------------- |
| id | As returned in `GET /servers` | "E8879F3D-95AE-4714-BC04-9B271C2BC52D" |

###### Sample Return

```
{
"status": 1
// 1 for succeed, 0 for fail
}
```

If the `id` is invalid or fail to match any `id` in config, "status" = 0.

- #### Get current mode `GET /mode`

###### Sample Return

```
{
"mode": "auto"
}
```

`mode`∈ {"auto", "global", "manual"}.

- #### Switch mode `POST /mode`

###### Sample Return

```
{
"status": 1
// 1 for succeed, 0 for fail
}
```

If the `mode`∉ {"auto", "global", "manual"}, "status" = 0.

0 comments on commit e6f6ae6

Please sign in to comment.