Skip to content

Commit 11e05fc

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

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

HTTPAPI.md

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

0 commit comments

Comments
 (0)