Commit a9b5762f authored by ibuler's avatar ibuler

Modify api style guide info

parent acd98365
......@@ -21,14 +21,15 @@ https://example.org/api/
### 版本
将API的版本号放入URL
将API的版本号放入URL中, 由于一个项目多个app所以Jumpserver使用以下风格,
将版本号放到app后面
```
https://example.com/api/v1/
https://example.com/api/:app:/:version:/:resource:
https://example.com/api/assets/v1.0/assets [GET, POST]
https://example.com/api/assets/v1.0/assets/1 [GET, PUT, DELETE]
```
另一种做法是,将版本号放在HTTP头信息中,但不如放入URL方便和直观。Github采用这种做法。
### 路径
......@@ -37,11 +38,11 @@ https://example.com/api/v1/
举例来说 cmdb中的assets列表, idc列表
```
https://example.com/api/v1/assets
https://example.com/api/v1/assetgroups
https://example.com/api/v1/assetgroups/:id/assets
https://example.com/api/v1/assets/:id
https://example.com/api/v1/idcs
https://example.com/api/:app:/:version:/:resource:
https://example.com/api/assets/v1.0/assets [GET, POST]
https://example.com/api/assets/v1.0/assets/1 [GET, PUT, DELETE]
https://example.com/api/assets/v1.0/idcs [GET, POST]
```
一般性的增删查改(CRUD)API,完全使用HTTP method加上url提供的语义,url中的可变部分(比如上面提到的<role_id>
......
......@@ -11,7 +11,7 @@
├── README.md
├── install // 安装说明
├── logs // 日志目录
├── apps // 管理后台目录,也是各app所在目录
├── apps // 管理后台目录,也是各app所在目录
│ └── assets // app目录
│ │ ├── admin.py
│ │ ├── apps.py // 新版本django app设置文件
......@@ -35,7 +35,7 @@
│ │ ├── templatetags // 通用template tag
│ │ ├── utils.py // 通用的函数方法
│ │ └── views.py
│ ├── fixtures // 初始化数据目录
│ ├── fixtures // 初始化数据目录
│ │ ├── init.json // 初始化项目数据库
│ │ └── fake.json // 生成大量测试数据
│ ├── jumpserver // 项目设置目录
......@@ -45,5 +45,6 @@
│ │ └── wsgi.py
│ ├── manage.py
│ ├── static // 项目静态资源目录
│ ├── static // 项目多语言目录
│ └── templates // 项目模板目录
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment