From e6f6ae656c40181ae24263544772dbf19dd79702 Mon Sep 17 00:00:00 2001 From: yangziy Date: Mon, 17 Sep 2018 20:21:42 +0800 Subject: [PATCH] Add HTTP API document. --- HTTPAPI.md | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 HTTPAPI.md diff --git a/HTTPAPI.md b/HTTPAPI.md new file mode 100644 index 000000000..b33d8f1ee --- /dev/null +++ b/HTTPAPI.md @@ -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. \ No newline at end of file