深色模式
MODEX Core API
MODEX Core 提供统一的 RESTful API 接口,用于:
- 用户管理
- 认证与授权(JWT)
- 插件管理
- 扩展点调用
- 平台能力调度
所有接口默认基于 HTTP 协议,数据格式为 application/json。
默认服务地址:
http://127.0.0.1:8080
1. 认证与用户管理
1.1 用户注册
POST /register
注册一个新用户。
请求体
{
"username": "yangpeihao",
"password": "yangpeihao123"
}1.2 用户登录
POST /login
使用用户名与密码登录,返回 JWT Token。
请求体
{
"username": "yangpeihao",
"password": "yangpeihao123"
}1.3 手动生成 JWT
POST /api/jwt
管理员可为指定用户生成 Token。
Header
Authorization: Bearer <admin_token>
X-Plugin-ID: plugin.system.core
请求体
{
"username": "yangpeihao",
"ttl": 96000
}2. 基础健康检查
2.1 Ping
GET /ping
用于检测服务是否正常运行。
3. 插件管理 API
MODEX Core 采用插件化架构,所有插件相关接口均通过扩展点方式调用。
调用规范:
- 必须携带
Authorization: Bearer <token> - 必须携带
X-Plugin-ID: plugin.system.core
3.1 安装插件
POST /api/ep.system.plugin/plugin_meta/install
请求体
{
"plugin_file_path": "D:\\go\\plugins\\plugin.dev.first.zip",
"run_auto": true
}3.2 插件列表
POST /api/ep.system.plugin/plugin_meta/list
{}3.3 启动插件
POST /api/ep.system.plugin/plugin_meta/start
{
"plugin_ids": ["plugin.dev.first"]
}3.4 停止插件
POST /api/ep.system.plugin/plugin_meta/close
{
"plugin_ids": ["plugin.dev.first"]
}4. 扩展点机制
接口统一格式:
/api/{extension_point}/{service}/{method}
示例:测试扩展点 Echo
POST /api/ep.system.test/test_meta/echo
{
"message": "halo,yangpeihao"
}示例:跨插件调用
POST /api/extension.point.first/second_ep_service/echo_by_second
{
"first_param": "yph dahaoren"
}5. 请求规范
统一 Header
Authorization: Bearer <JWT_TOKEN>
X-Plugin-ID: <caller_plugin_id>
Content-Type: application/json
统一返回格式
{
"code": 0,
"message": "success",
"data": {}
}6. 设计思想
MODEX Core API 设计遵循:
- 插件优先(Plugin First)
- 扩展点驱动(Extension Point Driven)
- 核心最小化(Minimal Core)
- 服务化暴露能力(Service-Oriented)
- Go 原生高性能实现
我们构建的是一个可持续演化的工业软件平台内核。