Skip to content

Commit 07e845e

Browse files
committed
docs: add API document
1 parent d370dc0 commit 07e845e

File tree

2 files changed

+160
-0
lines changed

2 files changed

+160
-0
lines changed

doc/en-US/api.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Render page of specified path
2+
```
3+
GET <path>
4+
```
5+
Should work no matter tailing “/” is present or not in path.
6+
7+
Example:
8+
```sh
9+
curl http://localhost/ghfs/
10+
```
11+
12+
# Get JSON data of specified path
13+
```
14+
GET <path>?json
15+
```
16+
17+
Example:
18+
```sh
19+
curl http://localhost/ghfs/?json
20+
```
21+
22+
# Get contents of specified path as archive file
23+
Only work when "archive" is enabled.
24+
```
25+
GET <path>?tar
26+
GET <path>?tgz
27+
GET <path>?zip
28+
```
29+
30+
Example:
31+
```sh
32+
curl http://localhost/tmp/?zip > tmp.zip
33+
```
34+
35+
# Upload files to specific path
36+
Only work when "upload" is enabled.
37+
```
38+
POST <path>?upload[&json]
39+
```
40+
- Must use `POST` method
41+
- Must use `multipart/form-data` encoding type
42+
- Each file content use one part, field name is `file`
43+
44+
Example:
45+
```sh
46+
curl -F '[email protected]' -F '[email protected]' http://localhost/tmp/?upload
47+
```
48+
49+
# Create directories in specific path
50+
Only work when "mkdir" is enabled.
51+
```
52+
GET <path>?mkdir[&json]&name=<dir1>&name=<dir2>&...name=<dirN>
53+
```
54+
```
55+
POST <path>?mkdir[&json]
56+
57+
name=<dir1>&name=<dir2>&...name=<dirN>
58+
```
59+
60+
Example:
61+
```sh
62+
curl -X POST -d 'name=dir1&name=dir2&name=dir3' http://localhost/tmp/?mkdir
63+
```
64+
65+
# Delete files or directories in specific path
66+
Only work when "delete" is enabled.
67+
Directories will be deleted recursively.
68+
```
69+
GET <path>?delete[&json]&name=<dir1>&name=<dir2>&...name=<dirN>
70+
```
71+
```
72+
POST <path>?delete[&json]
73+
74+
name=<dir1>&name=<dir2>&...name=<dirN>
75+
```
76+
77+
Example:
78+
```sh
79+
curl -X POST -d 'name=dir1&name=dir2&name=dir3' http://localhost/tmp/?delete
80+
```

doc/zh-CN/api.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# 为指定路径显示页面
2+
```
3+
GET <path>
4+
```
5+
无论路径是否以“/”结尾,都应正常工作。
6+
7+
举例:
8+
```sh
9+
curl http://localhost/ghfs/
10+
```
11+
12+
# 获取指定路径JSON形式的数据
13+
```
14+
GET <path>?json
15+
```
16+
17+
举例:
18+
```sh
19+
curl http://localhost/ghfs/?json
20+
```
21+
22+
# 以打包文件形式获取指定路径下的内容
23+
仅在“archive”选项启用时有效。
24+
```
25+
GET <path>?tar
26+
GET <path>?tgz
27+
GET <path>?zip
28+
```
29+
30+
举例:
31+
```sh
32+
curl http://localhost/tmp/?zip > tmp.zip
33+
```
34+
35+
# 上传文件到指定路径
36+
仅在“upload”选项启用时有效。
37+
```
38+
POST <path>?upload[&json]
39+
```
40+
- 必须使用`POST`方法
41+
- 必须使用`multipart/form-data`编码
42+
- 每个文件内容占用一个段,字段名为`file`
43+
44+
举例:
45+
```sh
46+
curl -F '[email protected]' -F '[email protected]' http://localhost/tmp/?upload
47+
```
48+
49+
# 在指定路径下创建目录
50+
仅在“mkdir”选项启用时有效。
51+
```
52+
GET <path>?mkdir[&json]&name=<dir1>&name=<dir2>&...name=<dirN>
53+
```
54+
```
55+
POST <path>?mkdir[&json]
56+
57+
name=<dir1>&name=<dir2>&...name=<dirN>
58+
```
59+
60+
举例:
61+
```sh
62+
curl -X POST -d 'name=dir1&name=dir2&name=dir3' http://localhost/tmp/?mkdir
63+
```
64+
65+
# 在指定路径下删除文件或目录
66+
仅在“delete”选项启用时有效。
67+
目录将被递归删除。
68+
```
69+
GET <path>?delete[&json]&name=<dir1>&name=<dir2>&...name=<dirN>
70+
```
71+
```
72+
POST <path>?delete[&json]
73+
74+
name=<dir1>&name=<dir2>&...name=<dirN>
75+
```
76+
77+
举例:
78+
```sh
79+
curl -X POST -d 'name=dir1&name=dir2&name=dir3' http://localhost/tmp/?delete
80+
```

0 commit comments

Comments
 (0)