# 配置 mm API 接口

## 规则（Rules）

- api.json 位于 `api_{app}_{类型}/{接口名}/api.json`
- `path` 定义路由路径，`name` 全局唯一
- `method` 可选 `GET`、`POST`、`ALL`（同时支持 GET 和 POST）

## 方法（Methods）

### 步骤1：确定接口信息

| 信息 | 说明 | 示例 |
|:----|:-----|:------|
| 路由路径 | URL 访问路径 | `/api/user/info` |
| 接口名 | 唯一标识 | `api_user_info` |
| 请求方法 | GET/POST/ALL | `ALL` |
| 是否开放 | 是否对外暴露 | `true` |

### 步骤2：编写 api.json

```json
{
    "path": "/api/user/info",
    "name": "api_user_info",
    "title": "用户信息",
    "description": "获取用户基本信息",
    "method": "ALL",
    "scope": true,
    "cache": 0,
    "state": 1,
    "client_cache": false,
    "param_path": "./param.json",
    "oauth": {
        "sign_in": true,
        "gm": 0
    }
}
```

### 步骤3：验证路由

启动服务后通过 `/api/user/info` 访问接口，确认路由注册成功。

## 技巧（Tips）

- `scope: true` 对外开放，`scope: false` 隐藏（仅内部使用）
- `cache` 设置服务端缓存时间（分钟），0 表示不缓存
- `client_cache: true` 启用浏览器缓存（设置 Cache-Control 头）
- `param_path` 指向参数校验文件，不填则不校验
- 参考实现：`api_client/`、`api_web/`、`api_manage/` 下的 api.json
