Skip to content

Commit e6f6ae6

Browse files
committed
Add HTTP API document.
1 parent 739b040 commit e6f6ae6

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

HTTPAPI.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Features
2+
3+
* Check current status (on/off)
4+
5+
- Toggle the client
6+
7+
- Get server list
8+
9+
- Switch server
10+
11+
- Get current mode
12+
13+
- Switch mode
14+
15+
# Specification
16+
17+
- #### Check current status (on/off) `GET /status`
18+
19+
###### Sample Return
20+
21+
```
22+
{
23+
"enable": true
24+
}
25+
```
26+
27+
- #### Toggle the client `POST /toggle`
28+
29+
###### Sample Return
30+
31+
```
32+
{
33+
"status": 1
34+
// 1 for toggle succeed, 0 for fail
35+
}
36+
```
37+
38+
- #### Get server list `GET /servers`
39+
40+
###### Sample Return
41+
42+
```
43+
[
44+
{
45+
"active": 1,
46+
"id": "93C547E0-49C9-1234-9CAD-EE8D5C4A1A8F",
47+
"remark": "us1",
48+
// remark: as in Server Preferences Panel of the app.
49+
},
50+
{
51+
"active" : 0,
52+
"id" : "71552DCD-B298-495E-904E-82DA4B07AEF8",
53+
"remark" : "hk2"
54+
},
55+
{
56+
"active" : 0,
57+
"id" : "E8879F3D-95AE-4714-BC04-9B271C2BC52D",
58+
"remark" : "jp1"
59+
},...
60+
]
61+
```
62+
63+
- #### Switch server `POST /servers`
64+
65+
###### Argument
66+
67+
| Name | Description | Sample |
68+
| ---- | ----------------------------- | -------------------------------------- |
69+
| id | As returned in `GET /servers` | "E8879F3D-95AE-4714-BC04-9B271C2BC52D" |
70+
71+
###### Sample Return
72+
73+
```
74+
{
75+
"status": 1
76+
// 1 for succeed, 0 for fail
77+
}
78+
```
79+
80+
If the `id` is invalid or fail to match any `id` in config, "status" = 0.
81+
82+
- #### Get current mode `GET /mode`
83+
84+
###### Sample Return
85+
86+
```
87+
{
88+
"mode": "auto"
89+
}
90+
```
91+
92+
`mode`∈ {"auto", "global", "manual"}.
93+
94+
- #### Switch mode `POST /mode`
95+
96+
###### Sample Return
97+
98+
```
99+
{
100+
"status": 1
101+
// 1 for succeed, 0 for fail
102+
}
103+
```
104+
105+
If the `mode`∉ {"auto", "global", "manual"}, "status" = 0.

0 commit comments

Comments
 (0)